Today's time to meet the date ("Y-m-d h:i:s") is always the same as the actual time. So query the relevant information to know the reason, collation as follows. The cause of this phenomenon: starting from php5.1.0, PHP.ini added the Date.timezone option, which is turned off by default, which is the time zone displayed. The default is Greenwich Mean Time and our time (Beijing time) is just 8 hours. Workaround: 1, the simplest way is not to use php5.1 above version 2, modify the php.ini configuration file can find Date.timezone in php.ini and modify. Under WINDOWS php.ini generally in: C:/windows/php.ini Linux under the php.ini General:/etc/php.ini Follow the above tips to find php.ini under Date.timezone this line, if not found can be added by themselves. Remove the preceding semicolon, modify it to Date.timezone = "Asia/shanghai", and remember to restart the HTTP service (such as Apache2 or IIS). Date.timezone the value referenced after the semicolon, the values available in mainland China are: asia/chongqing, Asia/shanghai, Asia/urumqi (Chongqing, Shanghai, Urumqi, respectively) Taiwan available: Asia/macao, asia/ Hong_Kong, Asia/taipei (Macau, Hong Kong, Taipei) and Singapore: Asia/singapore foreigners seem to have leaked Beijing. Other available values are: Etc/gmt-8, Singapore, Hongkong, what is PRC PRC? PRC is the People's Republic of China Ah 3, if you must use more than php5.1 version, and can not modify the php.ini configuration file. (1) Add 8 hours to the PHP code processing time Date (' y-m-d h:i:s ', Time () +8*3600), and (2) Insert Date_default_timezone_set (XXX) on the initialization statement of the time, Or you can use Date_default_timezone_set (XXX) in the header to set my default time zone for Beijing time Date_default_timezone_set (' Asia/shanghai '). The format string can recognize the following format parameters for the strings in the format character Description Return Value Example Day — -D The day ordinal of a month with a leading zero 2-digit number 01 to 31D Day of the week, text representation, 3 letters Mon to Sunj The day ordinal of the month without leading zeros 1 to 31l (lowercase letters of "L") Day of the week, full text format Sunday to Saturdayn ISO-8601 format number represents the day of the week (PHP 5.1.0 new Plus) 1 (indicated Monday) to 7 (for Sunday) S English suffix, 2 characters, after the number of days per month st,nd,rd or th. You can use W with J. Day of the week, numbers indicate 0 (representing Sunday) to 6 (for Saturday) Z The day ordinal of the year 0-365 weeks — -W Week of the ISO-8601 format year, starting from Monday (PHP 4.1.0 New) Example: 42 (42nd Week of the year) month — -F month, full text format, such as January or March January to Decemberm A number represents the month, with a leading zero 01 to 12M Three letter abbreviation for month Jan to DECN The number represents the month, without leading zeros 1 to 12t The number of days that a given month should be 28-31 years — -L Whether it is a leap year If the leap year is 1, otherwise 0o ISO-8601 format year number. This is the same value as Y, except if the day of the Week (W) of the ISO belongs to the previous year or the next year. (PHP 5.1.0 new addition) examples:1999 or 2003Y 4-digit year in full representation Example: 1999 or 2003Y Year 2-digit representation Example: 99 or 03 Time — -A Lowercase morning and afternoon values AM or PmA Uppercase morning and afternoon values AM or PMB Swatch Internet Standard Time 000 to 999g Hours, 12-hour format, no leading zeros 1 to 12G Hours, 24-hour format, no leading zeros 0 to 23h Hours, 12-hour format, with leading zeros 01 to 12H Hours, 24-hour format, with leading zeros 00 to 23i Number of minutes with leading zeros 00 to 59>s Number of seconds with leading zeros 00 to 59> time zone — -E Time zone ID (PHP 5.1.0 new addition) Example: Utc,gmt,atlantic/azoresi Whether it is daylight saving time If daylight saving time is 1, otherwise 0O Hours of difference from GMT Example: +0200p Difference from GMT (GMT), between hours and minutes colon separated (PHP 5.1.3 New) Example: +02:00t The time zone in which this machine resides For example: EST,MDT ("translator note" in the full text format under Windows, such as "Eastern Standard Time", the Chinese version will show "China normal times"). Z The number of seconds of the slack offset. The time zone offset in the west of UTC is always negative, and the time zone offset to the east of UTC is always positive. 43200 to 43200 full Date/time — -C Date in ISO 8601 format (PHP 5 new) 2004-02-12t15:19:21+00:00r Date in RFC 822 format For example: Thu, Dec 16:01:07 +0200u The number of seconds since the Unix era (January 1 1970 00:00:00 GMT) started See Time () Category: PHP
http://www.bkjia.com/PHPjc/735872.html www.bkjia.com true http://www.bkjia.com/PHPjc/735872.html techarticle today's time to meet date (y-m-d h:i:s) is always the same as the actual time. So query the relevant information to know the reason, collation as follows. The reason for this phenomenon: starting from php5.1.0, ...