Javascript Date parsing returning strange results in Chrome

前端 未结 2 942
慢半拍i
慢半拍i 2021-02-08 17:37

I observed some strange Date behaviour in Chrome (Version 74.0.3729.131 (Official Build) (64-bit)). Following javascript was executed in the Chrome Dev Console:

         


        
2条回答
  •  情歌与酒
    2021-02-08 17:42

    This might be the case when all browsers follow their own standards for encoding date formats (but I am not sure on this part). Anyways a simple fix for this is to apply the toISOString method.

    const today = new Date();
    console.log(today.toISOString());

提交回复
热议问题