PDA

View Full Version : Matching a time output to user's time setting


Castel
11-11-2001, 02:28 AM
This code is slightly modified code from Mas*Mind's world times on index hack. Because I like it to be a standalone page and not make my index page longer then it already is.


<?php
error_reporting(7);

$templatesused='worldtimes_cols,worldtimes_rows';

require('./global.php');

$dateformat = "l,F jS";
$hourformat = "H:i";
$perrow = 1;

$timezones[-8] = "Los Angeles, Seattle";
$timezones[-7] = "Denver,Edmonton";
$timezones[-6] = "Chicago,Mexico City";
$timezones[-5] = "New York,Miami";
$timezones[-10] = "Honolulu";
$timezones[-9] = "Anchorage,Juneau";

$i=0;

while(list($timediff, $cities)=each($timezones)) {
$i++;
$servertime = $timeoffset - $timediff;
$timestamp = mktime (date("H")-$servertime, date("i"), date("s"), date("m"), date("d"), date("Y"));
$datetime = date($dateformat, $timestamp);
$hourtime = date($hourformat, $timestamp);
eval("\$citycol .= \"".gettemplate('worldtimes_cols')."\";");
if($i % $perrow == 0) {
eval("\$cityzones .= \"".gettemplate('worldtimes_rows')."\";");
unset($citycol);
}
}

eval("dooutput(\"".gettemplate('worldtimes')."\");");

?>


This results into this page: World Times (http://www.tekkenzaibatsu.com/forums/worldtimes.php)

I want to display an icon in the first colunm indicating if this is the user's timezone or not. Basicly matching $hourtime to the user's timesetting, but I can't figure out how so far.

Admin
11-11-2001, 12:08 PM
Inside your while loop, you can do something like this:
if ($timediff==$bbuserinfo[timezoneoffset]) {
// this is the offset the user it using
} else {
// it's not
}

Note, you will need to do this:
$timezones[+8] = "Cities";
and NOT this:
$timezones[8] = "Cities";

Castel
11-12-2001, 12:08 AM
Ahh, I had my code bit in the wrong spot. Thanks for the help FireFly!