Jump to content

Insert date into object


Recommended Posts

How can I add a date to an object without it changing due to the timezone? 


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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...