Foreword
The introduction of this article covers the following parts:
1. What does time standard refer to? What are the concepts, relationships and differences between UCT and GMT?
2. What are the standards for time expression?
3. Time processing in JS
Date and time standards
Not much to say about date standards - the AD era
is to commemorate the birth of the Jewish Jesus (Christ). The year he was born was 1 AD, and the year before his birth was called "n year BC"
Simply speaking, the standard of time is the starting point of time. As for years, for example, if we did not use the AD chronology, it would probably be very difficult for the world to communicate (the 54th year of the People’s Republic of China would probably confuse many foreigners)
There are actually quite a lot of time standards.
Atomic Time · Coordinated Universal Time (UTC) · Greenwich Mean Time (GMT) · Earth Time (TT) · Mechanical Time (DT)
In program development and even in daily life, UTC and GMT are more common .
UTC is the English abbreviation of Universal Time Coordinated. It is a second-based time scale stipulated and recommended by the International Radio Advisory Committee and maintained by the International Time Bureau (BIH). UTC is equivalent to the mean solar time on the prime meridian (that is, 0 degrees longitude), which was expressed in Greenwich Mean Time (GMT) in the past. Beijing time is 8 hours ahead of UTC time, based on 0000 UTC on January 1, 1999. For example, UTC time is zero o'clock, and Beijing time is 8 o'clock in the morning on January 1, 1999.
GMT (Greenwich Mean Time) is Greenwich Mean Time:
Since the earth’s orbit is not circular, and its speed changes with the distance between the earth and the sun, the apparent solar time lacks uniformity. The apparent length of the solar day is also affected by the inclination of the Earth's rotation axis relative to its orbital plane. To correct for these inhomogeneities, astronomers calculated the effects of the Earth's non-circular orbit and polar axis tilt toward the Sun. Mean solar time refers to the revised apparent solar time. The mean solar time on the Greenwich meridian is called Universal Time (UT0), also called Greenwich Mean Time (GMT).
In order to ensure that the difference between Coordinated Universal Time and Universal Time (UT1) will not exceed 0.9 seconds, positive or negative leap seconds will be added to Coordinated Universal Time when necessary. Therefore, there will be a number of whole seconds difference between Coordinated Universal Time and International Atomic Time (TAI). The International Center for Earth Rotation Affairs (IERS) in Paris is responsible for deciding when to add leap seconds.
The relationship between the two:
UTC = GMT +/- 0.9 s
Therefore, UTC needs to make "leap seconds" to control the difference between the two.
You can ignore all the above introductions. In a word, UTC and GMT are world standard time, and the difference between them is very small.
Date and time representation standard
The calculation standard for date and time is now available. But the expression can also vary widely.
2013/08/16
08/16/2013
13/08/16
. . . . .
So, the International Organization for Standardization ISO came out and formulated an 8601 series of "Data Storage and Exchange Forms·Information Exchange·Date and Time Representation Methods".
It is currently the third edition of ISO8601:2004 to replace the first edition of ISO8601:1988 and the second edition of ISO8601:2000.
The main parts are listed:
1. Date representation
The year is 4 digits, the month is 2 digits, and the day in the month is 2 digits, for example, date (August 16, 2013) It can be expressed as 2013-08-16, or 20130816.
2. Calendar week and day representation
You can use 2 digits to represent the calendar week of the year;
Each calendar week starts on Monday, and Sunday is the 7th day
3. Time representation
Hours, minutes and seconds are all represented by 2 digits. For UTC time, a capital letter Z is added at the end. Other time zones are represented by the actual time plus the time difference. For example, 2:30 minutes and 5 seconds of UTC time is expressed as 14:30:05Z or 143005Z, and the Beijing time at that time is expressed as 22:30:05+08:00 or 223005+0800, which can also be simplified to 223005+08.
4. Combined representation of date and time
When expressing together, add a capital letter T in front of the time. If you want to express 5:30 minutes and 8 seconds on May 3, 2004, Beijing time, you can write it as 2004-05 -03T17:30:08+08:00 or 20040503T173008+08.
What needs to be mentioned in particular is:
Sunday is the first day of the week in the West
It is the last day in China.
That is, the ISO standards are consistent with Chinese customs. However, many software, languages, etc. are currently developed abroad, and their own habits have continued over time.
Date and time in Javascript
Method Description FF IE
Date() Returns the date and time of the current day. 1 3
getDate() returns the day of the month (1 ~ 31) from the Date object. 1 3
getDay() Returns the day of the week (0 ~ 6) from the Date object. 1 3
getMonth() returns the month (0 ~ 11) from the Date object. 1 3
getFullYear() Returns the year as a four-digit number from a Date object. 1 4
getYear() Please use getFullYear() method instead. 1 3
getHours() returns the hours (0 ~ 23) of the Date object. 1 3
getMinutes() returns the minutes (0 ~ 59) of the Date object. 1 3
getSeconds() returns the seconds of the Date object (0 ~ 59). 1 3
getMilliseconds() returns the milliseconds (0 ~ 999) of the Date object. 1 4
getTime() Returns the number of milliseconds since January 1, 1970. 1 3
getTimezoneOffset() Returns the difference in minutes between local time and Greenwich Mean Time (GMT). 1 3
getUTCDate() Returns the day of the month (1 ~ 31) from a Date object based on universal time. 1 4
getUTCDay() Returns the day of the week (0 ~ 6) from a Date object based on universal time. 1 4
getUTCMonth() Returns the month (0 ~ 11) from the Date object according to universal time. 1 4
getUTCFulYear() Returns the four-digit year from a Date object based on universal time. 1 4
getUTCHours() Returns the hour (0 ~ 23) of the Date object according to universal time. 1 4
getUTCMinutes() Returns the minutes (0 ~ 59) of a Date object according to universal time. 1 4
getUTCSeconds() Returns the seconds (0 ~ 59) of a Date object according to universal time. 1 4
getUTCMilliseconds() returns the milliseconds (0 ~ 999) of the Date object according to universal time. 1 4
parse() Returns the number of milliseconds from midnight on January 1, 1970 to the specified date (string). 1 3
setDate() sets the day of the month (1 ~ 31) in the Date object. 1 3
setMonth() sets the month (0 ~ 11) in the Date object. 1 3
setFullYear() Sets the year (four digits) in the Date object. 1 4
setYear() Please use the setFullYear() method instead. 1 3
setHours() Sets the hours (0 ~ 23) in the Date object. 1 3
setMinutes() Sets the minutes (0 ~ 59) in the Date object. 1 3
setSeconds() Sets the seconds (0 ~ 59) in the Date object. 1 3
setMilliseconds() Sets the milliseconds (0 ~ 999) in the Date object. 1 4
setTime() Sets a Date object in milliseconds. 1 3
setUTCDate() Sets the day of the month in the Date object (1 ~ 31) according to universal time. 1 4
setUTCMonth() Sets the month (0 ~ 11) in the Date object according to universal time. 1 4
setUTCFulYear() Sets the year (four digits) in the Date object according to universal time. 1 4
setUTCHours() Sets the hour (0 ~ 23) in the Date object according to universal time. 1 4
setUTCMinutes() Sets the minutes in the Date object (0 ~ 59) according to universal time. 1 4
setUTCSeconds() Sets the seconds in the Date object (0 ~ 59) according to universal time. 1 4
setUTCMilliseconds() Sets the milliseconds in the Date object (0 ~ 999) according to universal time. 1 4
toSource() Returns the source code of this object. 1 -
toString() Converts Date object to string. 1 4
toTimeString() Converts the time part of the Date object to a string. 1 4
toDateString() Converts the date part of the Date object to a string. 1 4
toGMTString() Please use toUTCString() method instead. 1 3
toUTCString() Converts a Date object to a string according to universal time. 1 4
toLocaleString() Converts Date object to string according to local time format. 1 3
toLocaleTimeString() Converts the time part of the Date object to a string according to the local time format. 1 3
toLocaleDateString() Converts the date part of the Date object to a string according to the local time format. 1 3
UTC() Returns the number of milliseconds between January 1, 1997 and the specified date, according to Universal Time. 1 3
valueOf() returns the original value of the Date object.
You can also ignore all the above. What needs to be mentioned in particular is:
Javascript treats Sunday as the beginning of the week. You have to be careful when using the getDay() method.
getDay() returns a value between 0-6, 2013/08/18 is Sunday, the return value is 0
Add by oscar999--> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Author" CONTENT="oscar999"> <script> var date = new Date("2013/08/18"); alert(date.getDay()); </script> </HEAD> <BODY>

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.