Page 1 of 1

Weird code behavior

Posted: Mon Nov 06, 2006 2:48 am
by itsmani1
When i run this bunch of code my own local machine it gives me following output:
November 12, 2006
Sunday, 09 pm
but when i run it on server it gives me following output:
December 31, 1969
Wednesday, 04 pm

Any reason to this problem?

Code: Select all

$dat1 = "2006-11-12T13:00:00";
$zd = date('P');
$convert_date = strtotime($dat1.$zd);
echo date("F d, Y", $convert_date).'<br>'.date("l, h a", $convert_date);
Thanks

Posted: Mon Nov 06, 2006 3:46 am
by jayshields
The server's date/time is set wrong?

Posted: Mon Nov 06, 2006 5:00 am
by Chris Corbyn
No that time is the UNIX epcoh. strtotime() has been tweaked many times over many versions of PHP. It's not the most consistent function across versions unfortunately.

Posted: Mon Nov 06, 2006 6:17 am
by itsmani1
so which function i should use? any suggestion
thanks

Posted: Mon Nov 06, 2006 6:36 am
by volka

Code: Select all

<?php echo 'version: ', phpversion(); ?>
what does this print on your (shared?) server?

http://www.php.net/ChangeLog-5.php wrote:Version 5.0.0 Release Candidate 1
18-Mar-2004
[...]
Added support for more ISO8601 datetime formats in strtotime(). (Moriyoshi) . Timezone specifier (ex. "20040301T02:00:00+19:00") .