Quick Navigation
DateTime
var date1 = new Date();
console.log(date1);
console.log("Year: " + date1.getFullYear());
console.log("Month: " + date1.getMonth());
console.log("Date: " + date1.getDate());
console.log("Hour: " + date1.getHours());
console.log("Minutes: " + date1.getMinutes());
console.log("Seconds: " + date1.getSeconds());
var date2 = new Date('December 17, 1995 03:24:00');
console.log(date2);
Output:
2019-02-16T04:19:44.909Z
Year: 2019
Month: 1
Date: 16
Hour: 4
Minutes: 19
Seconds: 44
1995-12-17T03:24:00.000Z
Convert from Epoch to Human Readable Date
var epoch = 1549505686;
var date = new Date(epoch * 1000);
console.log(date);
Output:
2019-02-07T02:14:46.000Z
Convert from Human Readable Date to Epoch
var d = new Date().valueOf();
var epoch = d / 1000;
console.log(epoch);
Output:
1550290986.779