Home > Mobile >  Small program how to obtain the Chinese standard time
Small program how to obtain the Chinese standard time

Time:10-04

Consult, new Data () method gets the current equipment only time, is there any way for Chinese standard time?

CodePudding user response:

New Data () to obtain the time followed by the sometimes, according to the time zone conversion for GMT + 0700 GMT + 0800

Novosibirsk, Thu Sep 12, 2019 14:51:06 GMT + 0700 (standard time)
Thu Sep 12, 2019 15:51:58 GMT + 0800 (China standard time)

According to new Data or (.) getTimezoneOffset calculated from (0 time zones, and then calculate the fixed time zones

GetTimezoneOffset () method can return to Greenwich mean time and time difference between local time, in minutes,


The function getTime (offset)
{
Var d=new Date ();
LocalTime=d.g etTime ();
LocalOffset=d.g etTimezoneOffset () * 60000;

//obtain the UTC time in msec
Utc=localTime + localOffset;
//create new Date object for company's city
//using supplied offset
Var nd=new Date (utc + offset (3600000 *));
//nd=3600000 + nd;
Utc=new Date (utc);
//return time as a string
$(" # local "). The HTML (nd) toLocaleString ());
$(" # utc "). The HTML (utc) toLocaleString ());
}
  • Related