简体   繁体   中英

PHP: Strtotime / date ignoring timezone?

having some trouslb with strtotime, its easier to show by example :)

date_default_timezone_set('Europe/London');             //  Set timezone to local / 
echo date("d/m/Y", strtotime("1-6-2003"));   // Expected: 01/06/2003    Got:    01/06/2003
echo date("d/m/Y", strtotime("16-12-2003")); // Expected: 16/12/2003    Got:    16/12/2003
echo date("d/m/Y", strtotime("10-12-03"));   // Expected: 10/12/2003    Got:    03/12/2010

Any ideas how to get around this problem? I am using strtotime to try and negate problems with users entering dates in different formats.

Thank you for reading,

Rik.

strtotime does not support that kind of date format. See the documentation for a list of supported formats. Read the documentation next time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM