General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 31st, 2003, 09:34 AM
Frederic Boije Frederic Boije is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Malmö - Sweden
Posts: 19 Frederic Boije User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #2  
Old August 2nd, 2003, 01:42 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
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

Reply With Quote
  #3  
Old August 4th, 2003, 06:57 AM
Frederic Boije Frederic Boije is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Malmö - Sweden
Posts: 19 Frederic Boije User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old August 4th, 2003, 11:58 AM
Frederic Boije Frederic Boije is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Malmö - Sweden
Posts: 19 Frederic Boije User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #5  
Old August 5th, 2003, 11:00 AM
Frederic Boije Frederic Boije is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Malmö - Sweden
Posts: 19 Frederic Boije User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Universal Time Management


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway