Skip to content

Instantly share code, notes, and snippets.

@lukehedger
Created January 2, 2014 10:49
Show Gist options
  • Save lukehedger/8217558 to your computer and use it in GitHub Desktop.
Save lukehedger/8217558 to your computer and use it in GitHub Desktop.
Add leading zeros (to months etc)
now = Date.now()
date = new Date(now)
m = ('0'+(date.getMonth()+1)).slice(-2) // add leading zero to month
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment