Confusion about UTC time, GMT time and Local time in javascript

1, which standard time is the default in js?
according to the Date object defined on MDN, the time of js is based on the UTC time of January 1, 1970. Why is the GMT time printed through the console?
then someone said: it is generally believed that GMT and UTC are basically the same, the same as the local time in London, England. The essence of UTC emphasizes a more accurate world time standard than GMT. It"s actually a more accurate GMT, so why didn"t js change new Date () to UTC time? And there are many built-in UTC-related conversion methods.

2, confusion with local time (Beijing time CST)
what we use in real life is Beijing time, that is, CST time, which is 8 hours different from UTC/GMT, so what is the current time coming out through new, and does it include the 8-hour jet lag?
Mon Sep 10 2018 11:22:55 GMT+0800 (China Standard time)

Jun.06,2021

outputs Beijing time, that is, GMT | | UTC + 8 hours time difference

GMT + 0800 means GTM (Greenwich mean time) + 0800 (positive eight time zone)


timestamp, the console prints the result of toString execution. According to the ecma specification, the execution is ToDateString method, so how is this method defined?

The toDateString () method returns the date portion of a Date object in human readable form in American English.

so it is not a standard, for example, in firefox it is not GMT time


Which standard time is the default in

1.js? -> this depends on where you look, such as the chrome/IE console, and it depends on how they are implemented and which default display is used-- so it has something to do with the engine

2. Take chrome browser as an example:

let d = new Date();
d // Mon Sep 10 2018 13:33:47 GMT+0800 ()    --GMT+0800  8

you can see that this is obviously a time with a time zone added

d.getUTCHours() 
//5

d.getHours()
//13
d.toGMTString()
//"Mon, 10 Sep 2018 05:33:47 GMT"
d.toLocaleString()
//"2018/9/10 1:33:47"

as for the method names of existing methods, we can't delve into too much, because the code is all written by programmers, and it is possible to maintain it later

.
Menu