Created
December 18, 2012 21:58
-
-
Save jonkemp/4332432 to your computer and use it in GitHub Desktop.
Get the current date and the date 30 days ago. Then format the dates like this: M/D/YYYY. This an example of date manipulation in JavaScript.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get the current date and the date 30 days ago. | |
* Then format the dates like this: M/D/YYYY. | |
*/ | |
var diff = 2592000000; | |
var now = new Date(); | |
var diffDate = new Date( now.getTime() - diff ); | |
var nowPrint = [ now.getMonth() + 1, now.getDate(), now.getFullYear() ].join("/"); | |
var diffPrint = [ diffDate.getMonth() + 1, diffDate.getDate(), diffDate.getFullYear() ].join("/"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment