v Dates And Times - Javascript

Dates And Times


// Create current date and time
var current = new Date();

// Output to log
console.log('current:', current);

// Specific date: Year, month (zero based!), day, hour, minute, second, and millisecond
var birthday = new Date(1983, 08, 15, 11, 33, 30, 0);

// Output to log
console.log('birthday:', birthday);

// Date in string format
var stringDate = new Date("2015-11-21");

// Output to log, printing only the year, month, day, and day of the week
console.log('stringDate:', stringDate.toDateString());