from unix timestamp to datetime

前端 未结 8 1034
日久生厌
日久生厌 2020-12-01 09:28

I have something like /Date(1370001284000+0200)/ as timestamp. I guess it is a unix date, isn\'t it? How can I convert this to a date like this: 31.05.201

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 09:51

    Looks like you might want the ISO format so that you can retain the timezone.

    var dateTime = new Date(1370001284000);
    dateTime.toISOString(); // Returns "2013-05-31T11:54:44.000Z"
    

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString

提交回复
热议问题