iso date string to date javascript code example
Example 1: iso date javascript
const event = new Date('05 October 2011 14:48 UTC');
console.log(event.toString());
console.log(event.toISOString());
Example 2: iso 8601 date to Js date
function parseDate(input) {
return new Date(input);
}
parseDate("2021-02-26T11:30:00.000Z")
Example 3: transform a date to iso string to date in javascript
date = new Date(dateISOString);
year = date.getFullYear();
month = date.getMonth()+1;
day = date.getDate();
hour = date.getHours();
minutes = date.getMinutes();
if (day < 10) {
dt = '0' + dt;
}
if (month < 10) {
month = '0' + month;
}
return finalDate = `${year}/${month}/${day} - ${hour}h:${minutes}mn`;