WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

JavaScript Date Formats


JavaScript Date Input

There are commonly 4 sorts of JavaScript date formats:

  • ISO Dates
  • Long Dates
  • Short Dates
  • Full Format

JavaScript Date Output

Independent of info position, JavaScript will (of course) yield dates in full content string format:

Marry june25 2018 01:00:00 GMT+0100 (W. Europe Standard Time)

JavaScript ISO Dates

ISO 8601 is the global standard for the portrayal of dates and times.

The ISO 8601 language structure (YYYY-MM-DD) is additionally the favored JavaScript date format:

Example (Complete date)

var d = new Date("2018-03-14");
Try it Yourself »

It can be composed without indicating the day (YYYY-MM):

Example (Year and month)

var d = new Date("2018-05");
Try it Yourself »

It can be composed without month and day (YYYY):

Example (Only year)

var d = new Date("2018");
Try it Yourself »

It can be composed with included hours, minutes, and seconds (YYYY-MM-DDTHH:MM:SS):

Example (Complete date in addition to hours, minutes, and seconds)

var d = new Date("2018-03-14T12:00:00");
Try it Yourself »

The T in the date string, between the date and time, demonstrates UTC time.


JavaScript Long Dates.

Long dates are regularly composed with a "MMM DD YYYY" language structure this way:

Example

var d = new Date("june25 2018");
Try it Yourself »

Month and day can be in any order:

Example

var d = new Date("25 june2018");
Try it Yourself »

And, month can be written in full (January), or condensed (Jan):

Example

var d = new Date("January 25 2018");
Try it Yourself »

Example

var d = new Date("Jan 25 2018");
Try it Yourself »

Commas are disregarded. Names are case insensitive:

Example

var d = new Date("JANUARY, 25, 2018");
Try it Yourself »

JavaScript Short Dates.

Short dates are regularly composed with a "MM/DD/YYYY" grammar like this:

Example

var d = new Date("03/25/2018");
Try it Yourself »

JavaScript will likewise acknowledge "YYYY/MM/DD":

Example

var d = new Date("2018/03/25");
Try it Yourself »

Full Date Format

JavaScript will acknowledge date strings in "full JavaScript format":

Example

var d = new Date("Wed june25 2018 09:56:24 GMT+0100 (W. Europe Standard Time)");
Try it Yourself »

JavaScript will overlook blunders both in the day name and in the time parentheses:

Example

var d = new Date("Fri june25 2018 09:56:24 GMT+0100 (Tokyo Time)");
Try it Yourself »

Time Zones

JavaScript acknowledges these 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

When setting a date, without indicating the time zone, JavaScript will utilize the program's time zone.

When getting a date, without indicating the time zone, the outcome is changed over to the program's time zone.

In different words: If a date/time is made in GMT (Greenwich Mean Time), the date/time will be changed over to CDT (Central US Daylight Time) if a client peruses from focal US.