-
Notifications
You must be signed in to change notification settings - Fork 4
Date
itsgreggreg edited this page Sep 22, 2015
·
1 revision
// Create a Date Object
var rightNow = new Date();
// Display the date as a string;
rightNow.toString();
// Shorthand for (new Date()).getTime();
Date.now();
// Actual date representation (seconds since unix epoch)
rightNow.getTime();
// Get individual parts
rightNow.getMinutes();
rightNow.getSeconds();
rightNow.getMiliseconds();
rightNow.getMonth();
// Create a specific date
var myBirthday = new Date(1984,8,22);
now.getTime() - myBirthday.getTime() === now - myBirthday;
// In our timezone this is epoch:
Date.parse("December 31, 1969, 18:00:00");