The time you encounter date ("Y-m-d h:i:s") today is always not the same as the actual time. So query the relevant information to know the reason, sorted as follows. The reason for this phenomenon: starting with php5.1.0, PHP.ini added the Date.timezone option, which is turned off by default, which is the time zone shown. The default is the Greenwich Mean Time and our time (Beijing time) is just 8 hours. Solution: 1, the simplest way is not to use php5.1 above version 2, modify php.ini configuration file can find Date.timezone in php.ini and modify. WINDOWS under PHP.ini General in: C:/windows/php.ini Linux php.ini General in:/etc/php.ini Follow the instructions above to find the Date.timezone line under PHP.ini, if you cannot find it, you can add it yourself. 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 semicolon following value reference, Mainland China available values are: asia/chongqing, Asia/shanghai, Asia/urumqi (Chongqing, Shanghai, in turn) URUMQI) Taiwan available: Asia/macao, Asia/hong_kong, Asia/taipei (Macao, Hong Kong, Taipei) Singapore: Asia/singapore Foreigners seem to have leaked Beijing. Other available values are: etc/gmt-8, Singapore, Hongkong, PRC PRC? PRC is the People's Republic of China 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 to get the correct Chinese time date (' y-m-d h:i:s ', Times () +8*3600); (2) Add Date_default_timezone_set (XXX) to the initialization statement about the time, orThe page header uses Date_default_timezone_set (XXX) to set my default time zone for Beijing Times date_default_timezone_set (' Asia/shanghai ') is also OK. Format strings identify the string format character description for the following format parameter--d the day ordinal of the month, with a leading zero of 2 digits 01 The day of the week of D, the text indicates that the 3-letter Mon to the day of Sun J Month, without leading 1 to L (lowercase letter of "L") days of the week, full text format Sunday to Saturday N ISO-8601 format number of weeks In the first days (PHP 5.1.0) 1 (for Monday) to 7 (for Sunday) S, after the number of days after the English suffix, 2 characters st,nd,rd or th. It can be used with J. The day of the W week, the number of days in the 0 (for Sunday) to 6 (for Saturday) the day 0-365 weeks of the year in Z, the first weeks of the--w ISO-8601 format year, starting every week from Monday (PHP 4.1.0 New) For example: 42 (That year 42nd week) Month--f month, full text format, such as January or March January to the month of December m digits, with a leading 1 to m three acronyms month from the month to Dec n digits , without leading 1 to t the number of days in a given month is 28-31 years--l is a leap year if it is a leap period of 1, otherwise 0 o ISO-8601 format years number. This is the same value as Y, except if the ISO number of weeks (W) belongs to the previous year or the next year, then the year is used. (PHP 5.1.0) examples:1999 or 2003 y 4 digits fully represented year for example: 1999 or 2003 Y 2 digits for example: 99 or 03 time--a lowercase morning and afternoon value am or pm a large Morning and afternoon value am or PM B Swatch Internet Standard 000 to 999 g hours, 12-hour format, no leading 1 to g hours, 24-hour format, no leading 0 To h hours, 12-hour format, has a leading 1 to h hours, 24-hour format, with leading 000 to I have a leading zero minutes of 00 to 59> s seconds, with a leading 0 to 59> time zone--e time zone identification (PHP 5 .1.0 new addition) For example: Utc,gmt,atlantic/azores I is daylight saving time if it is daylight saving time or 1, otherwise 0 O is the number of hours that differs from Greenwich Mean time: +0200 P and Greenwich Mean Time (GMT), and the hour and minutes are separated by colons (PHP 5 .1.3 New) For example: +02:00 T the time zone where the machine is located is for example: Est,mdt ("translator" under Windows for full text format, such as "Eastern Standard Time", the Chinese version will show "China standard Times"). The number of seconds for the Z-slack offset. The time zone offset to 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 ISO 8601 format Date (PHP 5 new) 2004-02-12t15:19:21+00:00 R RFC 822 format date For example: Thu, DEC 2000 16:01 : +0200 U The number of seconds since the start of the Unix era (January 1 1970 00:00:00 GMT) See Time () Category: PHP
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.