Weird code behavior

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Weird code behavior

Post 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
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

The server's date/time is set wrong?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

so which function i should use? any suggestion
thanks
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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") .
Post Reply