js iso string to date code example
Example 1: js string to date
var myDate = new Date("2013/1/16");
var str = "2013/1/16";
var strToDate = new Date(str);
Example 2: parse date from string in js
Date.parse(dateString)
//dateString is like 2020-10-10 / 2020-10-10T10:20:20
Example 3: how to get time and date from iso string javascript
const myDate = "2012-10-16T11:00:28.556094Z";
const time = new Date(myDate).toLocaleTimeString(
{ timeStyle:
// Output: "11:00"
Example 4: iso to date javascript
date = new Date(
date.getFullYear()+
Example 5: iso to date javascript
date = new Date(
year = date.getFullYear();
month = date.getMonth()+1;
dt = date.getDate();
if (dt < 10) {
dt =
}
if (month < 10) {
month =
}
console.log(year+
Example 6: 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 =
}
if (month < 10) {
month =
}
return finalDate = `${year}/${month}/${day} - ${hour}h:${minutes}mn`;