Hi, I've been trying to get my head around timezones and how to allow users to set their zone and update the times accordingly.

Basically, I have a unix timestamp in the database and i want to be able to update it to a users timezone which is also set in the database and display it as a readable date and time. This may of been answered but i couldn't find it in my 2 days of searching

I'd prefer to be given the actual code and not just linked to php documentation because that hasn't been much help to me.

Thanks in advance, Ryan

I couldn't get the example to work. I must of been doing something wrong, But a friend has been able to help me out in my problem.

It uses the pear date package. It's done exactly what i wanted it to and the code is easier to understand too

// include class
include ("Date.php");
$time = $row['time'];
// initialize object
$d = new Date($time);
$utz = $settings['tz']; // Users timezone setting
// set local time zone
$d->setTZByID("GMT");

// convert to foreign time zone
$d->convertTZByID($utz);

// retrieve converted date/time
echo $d->format("%A, %d %B %Y %T");
?>
commented: Thanks for sharing +6
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.