onelove
onelove

Reputation: 53

strtotime compatibility

Ok this relates to another question I have asked but as I have now pinpointed the issue I thought it would be clearer on a new question.

The problem I am having relates to strtotime under PHP 4.4

I have a larger script that is failing under PHP 4.4 but works under PHP 5+

To check it was this I wrote the following and copied it to two servers one running PHP 4.4 and the other PHP 5.3.

<?php
  $my_time = '2013-03-18T21:38:58.000Z';
  $my_time = strtotime($my_time);
  echo $my_time;

?>

The output under PHP 4.4 was: -1

The output under PHP 5.3 was: 1363642738

Is there a way to get the same result under PHP 4.4 as 5.3??

Thanks in advance for any help!

Upvotes: 0

Views: 254

Answers (2)

Syndrose
Syndrose

Reputation: 112

I don't have an installation of PHP 4 to test with, but try removing the .000Z from the end, all the examples on the strtotime page on PHP.net don't have that bit PHP 4.4 may not support it. If that works ultimately you can parse any time stamps with a substr($my_time, 0, 19)

Upvotes: 1

Corbin
Corbin

Reputation: 33457

-1 was the failure code for PHP < 5.1. This makes me think that PHP 4 can't parse that string.

This means you'll have to use a format both versions support. As a hack, you could do some string manipulation. If you can change the format of the string though, that's your best route. (Actually, your best route is to run the hell away from PHP 4.)

Upvotes: 3

Related Questions