Reputation: 403
I have REST API's and calling these API's from my React front end. Rest of my data goes smoothly and correctly except time.
I am using new Date()
object. REST API receives the date correct but time is a not correct.
"alert(new Date());" gives correct value though.
Upvotes: 0
Views: 1131
Reputation: 551
var now = new Date();
var utc = new Date(now.getTime() + now.getTimezoneOffset() * 60000);
Please try this, utc is the time you are interested in I guess.
Upvotes: 1