开发者

Timezones, daylight saving etc

We have a site that currently runs auctions at a certain time (picked by user) this was all working fine, as when the server hit that time the auction would start. We then had to add timezones, dependant on where the user lived. This would then add or take away a certain amount of hours depending on th开发者_StackOverflow中文版e drop-down selected, we again had this working fine, but then everything when potty when the clocks went forward, took me a while to work out that daylight saving now managed to break everything.

I know there is a solution to this problem as many people must have come across it, but I can't seem o work it out.

Our server currently runs UTC.

Any help on this would be great...


I'm not 100% on this, but I would say that provided your timezone database (part of your linux system) is up-to-date then you should be able to do this:

<?php
$currentTimezone = date_default_timezone_get();
date_default_timezone_set($usersTimezone);
echo date('j F Y G:i:s'); // Time shown in user's timezone, DST accounted for
date_default_timezone_set($currentTimezone);
?>

If you look through PHP's date functions there are probably less twisty ways to do this. I'm just not very clued up on those functions ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜