|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Universal Time Management
I have been building an auction site for a customer, and everything seems to work fine. It is built in PHP, running in an Linux environment using MySQL.
But after the first version was up, the customer wanted to move the site from Sweden (the site is swedish) to the States. After a while I discovered that we (Sweden vs USA) are not switching from summer to winter time in the same manner. So I had to adjust it manually last time the error occurred. When talking to the web hosting company in the States, they said that they are running the server under what they call "Standard Pacific Time". My question is: is there any time module that can compensate for summer/winter time and time differences from different timezones in a nice way? |
|
#2
|
|||
|
|||
|
Hi Frederic,
Are you looking just to display the times in Sweidsh time, or are you looking to offer different time zoning options to your visitors (similar to vBulletin)? If you're looking to simply convert the times, you can do so using PHP's gmdate() function. Let me know if that's what you're looking for...
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#3
|
|||
|
|||
|
Yes, I just want to display the time in swedish time. But the crucial thing is that I want to know for sure that it compensates for the differences between summer and wintertime between USA and Sweden.
Do you know if that is the case? /Fritz da Cat |
|
#4
|
|||
|
|||
|
OK - this is the sum of it all:
gmdate() function doesn't give me the right time. When I use gmdate, I am still one hour behind accurate time here in Sweden.... The Support Guy from by the web hotel said it is because the server is set to Standard Pacific Time , and... -"it can't be changed!!!" So, here I am, knowing NADA about the SPT, trying to compensate for the gmdate() function to give me the right time. Is there any library out there to fix this, or is there any friendly code poets out there in search of good souls to save? |
|
#5
|
|||
|
|||
|
OK - after seeking knowledge in cyberspace, I became a bit wiser and a bit older.
I have made a script that gets SPT time and converts it into UTC time (or GMT as it used to be called) and then takes into account that sweden shifts from winter into summer time (+1 Hours). The thing is that this shift from winter into summertime is done on specific shifting dates every year. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Timetest</title> </head> <body> <? // Get SPT from server and add 8 hours to get standard UTC time $utc = time() + 28800; // Get the Year, Month and Day from this... $year=date('Y', $utc); $month=date('n', $utc); $day=date('j', $utc); $time=date('h', $utc); if ($year=='2003') { $mar='30'; $oct='26'; } else if ($year=='2004') { $mar='28'; $oct='31'; } else if ($year=='2005') { $mar='27'; $oct='30'; } else if ($year=='2006') { $mar='26'; $oct='29'; } else { $mar='24'; $oct='27'; } // Swedish summertime is +1 Hour from regular UTC time // therefor we must compensate for this. // - Summertime begins 02.00 and becomes 03.00 // - Wintertime begins 03.00 and becomes 02.00 // If the month is between mars and october check... if ($month>='3' && $month<='10') { if (($month=='3' && $day<=$mar && $time<'2')||($month=='10' && $day>=$oct && $time<'3')) { $timedifference='0'; } else { $timedifference='1'; } } else { $timedifference="0"; } $mins='60'; $secs=($mins*$mins); $change=($timedifference*$secs); $se_time = date("Y m d H:m:s", $utc + $change); ?> <table> <tr> <td>Standard Pacific Time</td> <td><? print date("Y m d H:m:s"); ?></td> </tr> <tr> <td>Summer/wintertime compensation </td> <td><? print $change ?> (seconds)</td> </tr> <tr> <td>Swedish time</td> <td><? print $se_time ?></td> </tr> </table> </body> </html> |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Universal Time Management |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|