简体   繁体   中英

PHP strtotime to return as UTC timestamp?

Its a bit of a sever difference problem. On my local dev. server Im using:

<?php print strtotime($date." UCT"); ?>

The above code gives me the correct timestamp for my timezone. HOWEVER, the same code returns false on the live server.

The live server has a lower version of php installed and I imagine that to be the problem.

What I'm looking for is an alternative to the above line of code.

I could use the normal strototime without the." UCT" part and add in 2hours but would rather have PHP handle timezones.

$date looks like this: 2011-05-25 05:48:00

<?php print strtotime($date." UTC"); ?>

instead of

<?php print strtotime($date." UCT"); ?>

PHP warning on PHP documentation page, no support for UCT there:

http://www.php.net/manual/en/timezones.others.php

Warning

Please do not use any of the timezones listed here (besides UTC), they only exist for backward compatible reasons.

And here is latest PECL timezon database:

http://pecl.php.net/get/timezonedb

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