To do the project encounter the problem of the pit, need to get time zone in accordance with the timeline of the axis. For this search for a long time on the internet there is no JS code description to this aspect, finally I turned the next high school geography to write a function out.
This figure shows that the world is divided into 0 time zones, things 1-11 zones, and 12th time zones. Here's what I wrote about JS's function based on time zone output:
<! DOCTYPE html> <meta charset="Utf-8"> <meta http-equiv="X-ua-compatible" content="Ie=edge,chrome=1"> <title>Time zone timing based on time zone</title> <meta name="Blog" content="http://www.cnblogs.com/manfredHu/"> <meta name="Author" content="Manfredhu"><body> <scripttype="Text/javascript"> //function to get the time of the standard Time zone function Getlocaltime(I) { //Parameter i is the time zone value number, for example, Beijing for the East Eight in the 8, West 5 input-5 if (typeof I !== ' number ') return; var D = New Date (); //Get the number of seconds from January 1, 1970 to the present var Len = D.GetTime(); //Time offset difference between local time and GMT time var Offset = D.getTimezoneOffset() * 60000; //Get the current GMT var Utctime = Len + Offset; return New Date (Utctime + 3600000 * I); } Console.Log("******************* Eastern Time ************************************"); Console.Log("0 time Zone-London time:" + Getlocaltime(0)); Console.Log("East District-Berlin time:" + Getlocaltime(1)); Console.Log("Eastern District-Athens Time:" + Getlocaltime(2)); Console.Log("East Third District-Moscow time:" + Getlocaltime(3)); Console.Log("East quarter-time:" + Getlocaltime(4)); Console.Log("East Five district-Islamabad time:" + Getlocaltime(5)); Console.Log("East Six-Colombo time:" + Getlocaltime(6)); Console.Log("East seven-Bangkok time:" + Getlocaltime(7)); Console.Log("East eight-Beijing time:" + Getlocaltime(8)); Console.Log("East Nine-Tokyo time:" + Getlocaltime(9)); Console.Log("East 10-Sydney time:" + Getlocaltime(Ten)); Console.Log("East 12-Fiji Time:" + Getlocaltime( A)); Console.Log("******************* West time ************************************"); Console.Log("West District 10-Fiji Time:" + Getlocaltime(-Ten)); Console.Log("West Kowloon District-Alaska Time:" + Getlocaltime(-9)); Console.Log("West VIII-Pacific time (US and Canada):" + Getlocaltime(-8)); Console.Log("West Seven district-mountain time (US and Canada):" + Getlocaltime(-7)); Console.Log("West Six-central time (US and Canada):" + Getlocaltime(-6)); Console.Log("West Five district-Eastern time (US and Canada):" + Getlocaltime(-5)); Console.Log("West Quad-Atlantic Time (Canada):" + Getlocaltime(-4)); Console.Log("West Third District-Brasilia time:" + Getlocaltime(-3)); </script></body>
The GetTime function is used here to get the time difference from midnight January 1, 1970 to the present, to match the difference between the current local and GMT time to obtain the GMT standard value. That is, the utctime variable inside the function.
Finally, a result diagram is attached:
Click to view original: original address
JS a function that outputs time zones based on time zones