PHP time function date () solves the problem of 8 hour time difference on foreign servers.
cause
starting from php5.1.0, php.ini added with the date.timezone, and by default the closed
that is the time to display (whatever PHP command is used) is the Greenwich standard time
solution
method 1: add the following code before getting time:
date_default_timezone_set (PRC);
method two: to change php.ini, the specific operation is as follows:
open php.ini lookup to remove the front of the semicolon = behind and restart the service Pache2 or IIS, etc. can be
date.timezone=PRC
about XXX, the mainland available values are Asia/Chongqing, Asia/Shanghai, Asia/Urumqi, PRC (in turn, Chongqing, Shanghai, Urumqi, People's Republic of China)
Hong Kong and Taiwan areas available: Asia/Macao (Macao, Hongkong, Taipei)
and Singapore: Asia/Singapore
Other: Etc/GMT-8, Singapore, Hongkong
[color=#FF0000] method three: echo date (.Quot; Y-m-d H:i:s.quot; How many hours
date time format
date (.Quot; Y-m-d H:i:s.quot;); display format: year to month - day hour: minute:
related time parameters:
D - week, three English letters; such as.Quot; Fri.quot;
F - month, full name in English; such as.Quot, January.quot; 12 hour hours; In the case of.Quot; 00.quot; to.Quot; 23.quot;
g - 12 hours, less than two bits of no zero; such as.Quot; 1.quot, 12.quot;
G - 24 hours, less than two no null; Two digits, if less than two bits, such as:.Quot; 1.quot; to.Quot; 31.quot;
l - week, full name in English; such as.Quot; Friday.quot;
m - month, two digit numbers, if less than two; 01.quot;.Quot; 01.quot; two numbers, if less than two Three English letters such as:.Quot; 1.quot; to.Quot; 12.quot;
M month; such as.Quot; Jan.quot;
s - second; such as.Quot; 00.quot; O Kayoungwen ordinal number, two English letters; for example, the number of days of the designated month; for example: Quot; 28.quot; to.Quot; 31.quot;
U - the total number of seconds
w - Digital weeks, such as.Quot; 0.quot; (Sunday) to.Quot; 6.quot; (Saturday) years, four digits; e.g. T; to.Quot; 365.quot;