Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize ISO date display by JavaScript

Shulou Source: shulou.com Published: 2022-06-01 03:29:47 09月22日 Update

This article mainly explains "JavaScript how to achieve ISO date display", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "JavaScript how to achieve ISO date display" bar!

The JavaScript ISO date shows:

ISO 8601 is the international standard for showing date and time.

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

Instance (full date)

Var d = new Date ("2018-02-19")

The calculated date is relative to your time zone.

Depending on your time zone, the above results will change between February 18 and February 19.

ISO date (year and month)

It is possible to write a date without specifying a specific date (YYYY-MM):

Var d = new Date ("2015-03")

The time zone will change the results between February 28 and March 1.

ISO date (year only)

It is possible to write a date without specifying a specific month and day (YYYY):

Var d = new Date ("2018")

The time zone changes the results between December 31, 2017 and January 1, 2018.

ISO date (full date overtime, minutes, and seconds)

You can also add hours, minutes, and seconds (YYYY-MM-DDTHH:MM:SS) to write dates:

Var d = new Date ("2018-02-19T12:00:00")

The date and time are separated by the capital letter T.

UTC time is defined by the uppercase letter Z.

If you want to change the time relative to UTC, delete Z and replace it with + HH:MM or-HH:MM:

Example

Var d = new Date ("2018-02-19T12:00:00-08:30")

UTC (Universal Time Coordinated) is equivalent to GMT (Greenwich mean time).

Note: UTC, coordinated Universal time, also known as Universal Unified time, Universal Standard time, International coordinated time.

Omitting T or Z in the date-time string produces different results in different browsers.

Thank you for your reading, the above is the content of "JavaScript how to achieve ISO date display", after the study of this article, I believe you have a deeper understanding of how to achieve ISO date display in JavaScript, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Date time time zone result world between day solstice change learning different content international uppercase capital letters letters examples standards coordinated universal time also known as only Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL macOS Shulou Information Huawei Shulou Technology