PDA

View Full Version : Countdown + Timezones


ForKmaN
03-03-2002, 10:04 AM
Belwo is some code for a Countdown:
<?

$day = 10; // Day of the countdown
$month = 4; // Month of the countdown
$year = 2002; // Year of the countdown

// mktime is the marked time, and time() is the current time.
$target = mktime(0,0,0,$month,$day,$year);
$diff = $target - time();

$days = ($diff - ($diff % 86400)) / 86400;
$diff = $diff - ($days * 86400);
$hours = ($diff - ($diff % 3600)) / 3600;
$diff = $diff - ($hours * 3600);
$minutes = ($diff - ($diff % 60)) / 60;
$diff = $diff - ($minutes * 60);
$seconds = ($diff - ($diff % 1)) / 1;

printf("There are $days days, $hours hours, $minutes minutes, $seconds seconds until the next team meeting!");
?>
The problem is that is is the same for all timezones, I was wondering how I could make it work with all timzeones so teh countdown is different depending on what time zone your in and what timezone it is originally set on..

Thanks! If I get this working it shall lead toa vB hack ;)

Neo
03-03-2002, 10:31 AM
play with this code



$timestamp = time();

$hoursdiff = 7; //change this to how many hours minus UTC time you want to set the clock to

$hoursdiff = $hoursdiff * 3600;
$timestamp = $timestamp - $hoursdiff;

ForKmaN
03-03-2002, 11:43 AM
Thanks

any more comments?

I'm not the best at PHP but yeah :) I'd liek some more suggestions ..the more the merrier