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

6 Years
Discussion Span
Last Post by ryan-t

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

// convert to foreign time zone

// retrieve converted date/time
echo $d->format("%A, %d %B %Y %T");
Votes + Comments
Thanks for sharing
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.