PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
What date is it? (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: What date is it?
#890
sutterp (User)
Fresh Boarder
Posts: 19
graphgraph
User Offline Click here to see the profile of this user
What date is it? 3 Months ago Karma: 0  
I am getting a unix timestamp back in a database row, which I have to translate into a date to do date/time calculations.
When I run the program under php-gtk in Linux, I get different results than when running it under php-gtk in Windows XP.

Here is the program:

Code:
<?php
 $Year = 2008;
 $Month = 9;
 $Day = 30;
 $Hour = 16;
 $Minute = 00;
 $Second = 00;
 $TimestampC = mktime( $Hour,$Minute,$Second,$Month,$Day,$Year);
 print_r("TimestampC = (" . $TimestampC . ")\n");
 print_r("Date from TimestampC = (" . date("Y-m-d H:i:s",$TimestampC) . ")\n");

 $TimestampS = 1222790400;
 print_r("TimestampS = (" . $TimestampS . ")\n");
 print_r("Date from TimestampS = (" . date("Y-m-d H:i:s",$TimestampS) . ")\n");
?>
Here is the output from Windows XP, which is clearly not correct
Code:
C:\Documents and Settings\sutterp>php W:\gtk2\Example\php\timestamp.php
TimestampC = (1222790400)
Date from TimestampC = (2008-09-30 16:00:00)
TimestampS = (1222790400)
Date from TimestampS = (2008-09-30 16:00:00)
And here is the one from SuSE Linux,
Code:
sutterp@basilisk:~> php /data/www/jjh/intranet/gtk2/Example/php/timestamp.php
TimestampC = (1222761600)
Date from TimestampC = (2008-09-30 16:00:00)
TimestampS = (1222790400)
Date from TimestampS = (2008-10-01 00:00:00)
Same program, gets exported via samba share to windows. I believe that the way SuSE Linux creates the timestamp is correct, 1222790400 is 2008-10-01 00:00:00 and not 2008-09-30 16:00:00. However, its out by 8 hours, which is the timezone difference. Anybody experiencing similar problems How to fix? Peter And why is the board software dishonoring my Carriage Returns once I used the code tag, despite closing it with [\code]?
 
 
Last Edit: 2008/09/30 23:04 By sutterp.
  The administrator has disabled public write access.
#903
sutterp (User)
Fresh Boarder
Posts: 19
graphgraph
User Offline Click here to see the profile of this user
Re:What date is it? 3 Months ago Karma: 0  
Solved,

In linux, date_default_timezone is by default set to the timezone of the machine, in windows the date_default_timezone defaults to UTC, unless explicitly defined in php.ini
 
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2009. kksou.com. All Rights Reserved