Danish Sarwar
Danish Sarwar

Reputation: 403

REST API not receiving correct DateTime from React JS frontend

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

Answers (1)

Rizvan
Rizvan

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

Related Questions