How can a date be extracted from such a string?
Tue Apr 02 2019 12:00:00 GMT+0300 (Москва, стандартное время)
And bring it to this:
2019-01-21T08:59:45.84345Z
How can a date be extracted from such a string?
Tue Apr 02 2019 12:00:00 GMT+0300 (Москва, стандартное время)
And bring it to this:
2019-01-21T08:59:45.84345Z
const d1 = new Date('Tue Apr 02 2019 12:00:00 GMT+0300 (Москва, стандартное время)'); console.log(d1.toISOString());
The output you want is the ISO format .
The date being constructed from the string that you entered into the question itself will receive the correct timestamp
:
let d = new Date('Tue Apr 02 2019 12:00:00 GMT+0300 (Москва, стандартное время)') console.log(d.getTime()) console.log(d) d = d.toISOString() console.log(d)
The .toISOString()
method .toISOString()
date to ISO format .
By the way, the output that you generate at the input is generated by the usual toString()
the Date
object.
console.log(new Date().toString())
Source: https://ru.stackoverflow.com/questions/964104/
All Articles