PHPdate (& quot; Y-m-dH: I: s & quot;); get the current time difference of 8 hours solution (convert) PHPdate (Y-m-dH: I: when the time difference between the current and current time is 8 minutes, the swill will be able to cancel the resolution. (the reason for forwarding subin.org.cnblogpost#.html is :???????????????????? PHP date ("Y-m-d H: I: s"); get the current time difference of 8 hours solution (convert)
PHP date ("Y-m-d H: I: s"); get the current time difference of 8 hours solution
(To) http://subin.org.cn/blog/post/430.html
Cause:?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
??????? Php. date is added to ini. the timezone option is disabled by default, that is, the displayed time (no matter what php command is used) is the Greenwich mean time and our time (Beijing time) the difference is exactly 8 hours.
??????? Available timezone mainland China values: Asia/Chongqing, Asia/Shanghai, Asia/Urumqi, and PRC (Chongqing, Shanghai, Urumqi, and the People's Republic of China in sequence: asia/Macao, Asia/Hong_Kong, Asia/Taipei (Macau, Hong Kong, Taipei) and Singapore: Asia/Singapore Others: Etc/GMT-8, Singapore, Hongkong
Solution 1:
??????? Insert the following CODE before adding the time: (it seems you do not need to add )? Date_default_timezone_set (PRC );
Solution 2:
??????? Echo date ("Y-m-d H: I: s ",? Time () + 8*60*60 );
Solution 3 (modify the php. ini file ):
??????? Find php. "; date. timezone = "this line, remove"; "and change it to" date. timezone = PRC "(PRC: People's Republic of China), restart Apache, and solve the problem.
?
Appendix: date time format
Date ("Y-m-d H: I: s"); format: year-month-day hour: minute: Second
Related time parameters:
A-"am" or "pm "?
A-"AM" or "PM "?
D-a few days, two digits. if there are less than two digits, add the first zero. for example, "01" to "31 "?
D-the day of the week, with three English letters, for example, "Fri "?
F-month, full English name; for example: "January "?
H-12 hours; for example, "01" to "12 "?
H-24 hours, for example, "00" to "23 "?
For hours in the g-12 hour format, less than two do not fill in zero; for example: "1" to 12 "?
For hours in the G-24 hour system, less than two do not fill in zero; for example, "0" to "23 "?
I-minutes; for example: "00" to "59 "?
J-a few days, two digits, if less than two do not fill in zero; for example: "1" to "31 "?
L-the day of the week. Full name in English. for example: "Friday "?
M-month, two digits. if there are less than two digits, add zero in front. for example, "01" to "12 "?
N-month, two digits. if less than two digits are left blank, for example, "1" to "12 "?
M-month, with three English letters, for example, "Jan "?
S-seconds; for example: "00" to "59 "?
The end of the S-character is followed by an English ordinal number and two English letters, for example, "th", "nd "?
T-specifies the number of days in a month. for example, "28" to "31 "?
U-total number of seconds?
W-number, for example, "0" (Sunday) to "6" (Saturday )?
Y-year, four digits, such as: "1999 "?
Y-year, two digits, for example, "99 "?
Z-the day of the year, for example, "0" to "365"