Convert UTC Epoch to local date

后端 未结 16 1517
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 10:10

I have been fighting with this for a bit now. I’m trying to convert epoch to a date object. The epoch is sent to me in UTC. Whenever you pass new Date() an epoc

16条回答
  •  盖世英雄少女心
    2020-11-22 11:09

    Addition to the above answer by @djechlin

    d = '1394104654000';
    new Date(parseInt(d));
    

    converts EPOCH time to human readable date. Just don't forget that type of EPOCH time must be an Integer.

提交回复
热议问题