Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting java Date into Javascript Date

I have a map.I am converting the Map into a JSON Object.I am reading the JSON object and want to convert it into a Javascript date.

The Date object I send is read as 2012-12-19T06:00:00.000+0000 in js and I do not understand what is the T in this String.Anyone can throw light on this

like image 423
Harish Avatar asked Jan 30 '26 18:01

Harish


1 Answers

It is a string representation of a date as per the ISO 8601 specification. Here T stands for the beginning of the time portion of the datetime representation.

You can convert this representation to javascript date object using new Date('2012-12-19T06:00:00.000+0000').

You can use a regex to get only the date portion. The regex /\d{4}-\d{2}-\d{2}/.exec('2012-12-19T06:00:00.000+0000')[0] will give you the date portion alone.

Refer ISO 8601

like image 161
Arun P Johny Avatar answered Feb 02 '26 09:02

Arun P Johny



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!