12

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

CodeChap
  • 4,132
  • 6
  • 30
  • 40

2 Answers2

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

instead of

<?php print strtotime($date." UCT"); ?>
ajreal
  • 46,720
  • 11
  • 89
  • 119
  • 1
    @stefgosselin UCT is also valid timezone . http://www.php.net/manual/en/timezones.others.php – DhruvPathak Jun 08 '11 at 07:51
  • 2
    `Please do not use any of the timezones listed here (besides UTC), they only exist for backward compatible reasons.` – ajreal Jun 08 '11 at 07:58
0

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

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
DhruvPathak
  • 42,059
  • 16
  • 116
  • 175
  • 1
    Blatantly not pointing out that the @Good-bye likely made a typo is rude. – capikaw May 02 '15 at 18:37
  • @capikaw Or may be because it was not a typo, UCT is a supported name for "Universal Coordinated Time" , but is not supported in PHP , and that is what I had mentioned in my answer. See linux for example : ` ls /usr/share/zoneinfo/U* /usr/share/zoneinfo/UCT /usr/share/zoneinfo/Universal /usr/share/zoneinfo/UTC` A misinformed downvote is also rude IMHO. – DhruvPathak May 03 '15 at 05:37