Skip to content

Instantly share code, notes, and snippets.

@vishalkardode
Last active August 29, 2015 14:25
Show Gist options
  • Select an option

  • Save vishalkardode/429b1213a3990867bda4 to your computer and use it in GitHub Desktop.

Select an option

Save vishalkardode/429b1213a3990867bda4 to your computer and use it in GitHub Desktop.
var date = new Date();
var options = {
weekday: "short",
year: "numeric",
month: "2-digit",
day: "numeric"
};
date.toLocaleDateString("en", options);//en is language option, you may specify..
/*
Option Values and sample output
weekday narrow M
short Mon
long Monday
year 2-digit 01
numeric 2001
month 2-digit 01
numeric 1
narrow J
short Jan
long January
day 2-digit 01
numeric 1
hour 2-digit 12 AM
numeric 12 AM
minute 2-digit 0
numeric 0
second 2-digit 0
numeric 0
timeZoneName short 1/1/2001 GMT+00:00
long 1/1/2001 GMT+00:00
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment