Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON.stringify returns wrong value for the Date Object

the below code returns one day earlier,

var myJSON = JSON.stringify(new Date("02/02/1997"));
alert(myJSON);

myJSON variables returns "1997-02-01T18:30:00.000Z"

Why its returning wrong value.

Here, what does the meaning of "T18:30:00.000Z"

Is there any other way of converts the Date object to the String.

like image 653
Kalai Avatar asked Apr 17 '26 11:04

Kalai


1 Answers

Try this..

    var myJSON = JSON.stringify(new Date("02/02/1997").toLocaleString());
    alert(myJSON);
like image 102
Dee_wab Avatar answered Apr 19 '26 00:04

Dee_wab



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!