Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
521 views
in Technique[技术] by (71.8m points)

momentjs - Moment js, UnixTimeStamp Conversion going 1 day behind in US/Central

I need to convert unixtimestamp to date format in javascript. From the backend Db the date is Dec 31, 2025. But when parsing the date like below it is showing Dec 30, 2025. (Note. I am using US/Central time zone)

var unixdate = "/Date(1767119400000)/"; // This is how I receive date from DB
return moment.utc(moment(parseInt(unixdate.replace('/Date(', '').replace(')/', '')))).format('MMM DD, YYYY'); // Giving, "Dec 30, 2025"
//Expected is "Dec 31, 2025"

Note: I saw two similar questions related to one day difference. But those did not worked for me. And they are different from unix timestamp Moment.js sets dates to 1 day behind MomentJs Format One Day Behind

Any suggestion would be helpful.

question from:https://stackoverflow.com/questions/65948920/moment-js-unixtimestamp-conversion-going-1-day-behind-in-us-central

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...