JavaScript Tutorial – Date Format

There are 4 types of date formats in JavaScript:

  • ISO Date
  • Long Date
  • Short Date
  • Full Date

JavaScript ISO 8601 Date

ISO 8601 is the international standard for the representation of dates and times.

How to create ISO 8601 Date

<script type="text/javascript">
   var d = new Date("2013-11-25");
</script>
Try it yourself »

The ISO 8601 syntax (YYYY-MM-DD) is also the preferred JavaScript date format.

It can be written with added hours, minutes, and seconds (YYY-MM-DDTHH:MM:SS)

<script type="text/javascript">
   var d = new Date("2013-11-25T12:00:00");
</script>
Try it yourself »

JavaScript Long Date

Long dates are most often written with a “MMM DD YYYY” syntax.

How to create Long Date

<script type="text/javascript">
   var d = new Date("Nov 25 2013");
</script>
Try it yourself »

Month can be written in full (November ), or abbreviated (Nov). Year, month, and day can be in any order.

<script type="text/javascript">
   var d = new Date("2015 November 25");
</script>

JavaScript Short Date

Short dates are most often written with an “MM/DD/YYYY” syntax.

How to create date with Short Date Format

<script type="text/javascript">
   var d = new Date("11/25/2013");
</script>
Try it yourself »

Either “/” or “-” can be used as a separator

<script type="text/javascript">
   var d = new Date("11-25-2013");
</script>

Full Date Format

JavaScript will accept date strings in “full JavaScript format”

<script type="text/javascript">
   var d = new Date("Mon Nov 25 2013 09:56:24 GMT+0100 (W. Europe Standard Time)");
</script>
Try it yourself »

Valid JavaScript Time Zones

Time Zone Description
UTC Coordinated Universal Time
GMT Greenwich Mean Time
EDT (US) Eastern Daylight Time
CDT (US) Central Daylight Time
MDT (US) Mountain Daylight Time
PDT (US) Pacific Daylight Time
EST (US) Eastern Standard Time
CST (US) Central Standard Time
MST (US) Mountain Standard Time
PST (US) Pacific Standard Time