Guest Posted December 13, 2019 Share Posted December 13, 2019 How can I add a date to an object without it changing due to the timezone? Example: var mydate1 = new Date('2019-12-10 00:00:00'); var myobject1 = {"mydate": mydate1}; alert(mydate1 + " - " + JSON.stringify(myobject1)); Result is: Tue Jan 01 2019 00:00:00 GMT+0100 (Ora standard dell’Europa centrale) - {"mydate":"2018-12-31T23:00:00.000Z"} Thank you. Link to comment Share on other sites More sharing options...
Ingolme Posted December 13, 2019 Share Posted December 13, 2019 It's not the object that's the problem, it's JSON.stringify(). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now