refiking Posted January 21, 2008 Share Posted January 21, 2008 I have the timezone of each user stored in the 'zone' column of the 'users' table. How can I use that to change the time to fit them? Here's what I currently use: PRINT date("l, d M Y h:i A") Quote Link to comment https://forums.phpfreaks.com/topic/86982-change-time-based-on-timezone/ Share on other sites More sharing options...
cooldude832 Posted January 21, 2008 Share Posted January 21, 2008 when the user logs in set that in their session data, i like to do all my users data lilke <?php $_SESSION['UserData']['Username'] = "cooldude"; $_SESSION['UserData']['Timezone'] = "GMT"; ?> http://us.php.net/manual/en/function.date-timezone-set.php then on each load you can do <?php date_timezone_set($_SESSION['UserData']['Timezone']); ?> and your all set Quote Link to comment https://forums.phpfreaks.com/topic/86982-change-time-based-on-timezone/#findComment-444764 Share on other sites More sharing options...
refiking Posted January 21, 2008 Author Share Posted January 21, 2008 Fatal error: Call to undefined function: date_timezone_set() Here is my code: <?php include 'cont.php'; $sql = mysql_query("SELECT zone from users where user = '$username'"); while($row = mysql_fetch_assoc($sql)) { $zone = $row['zone']; } $_SESSION['UserData']['Timezone'] = $zone; date_timezone_set($_SESSION['UserData']['Timezone']); ?> Quote Link to comment https://forums.phpfreaks.com/topic/86982-change-time-based-on-timezone/#findComment-444784 Share on other sites More sharing options...
cooldude832 Posted January 21, 2008 Share Posted January 21, 2008 thats cause your on a php 4 server there is no simple way, but this was on php.net http://drakecms.sourceforge.net/index.php?option=content&id=32&Itemid=10 Quote Link to comment https://forums.phpfreaks.com/topic/86982-change-time-based-on-timezone/#findComment-444786 Share on other sites More sharing options...
refiking Posted January 21, 2008 Author Share Posted January 21, 2008 Isn't there a way that I can change the hour to +5 or something? If I can do that, I can just throw a few if statements in there and it'll be good to go. Quote Link to comment https://forums.phpfreaks.com/topic/86982-change-time-based-on-timezone/#findComment-444789 Share on other sites More sharing options...
The Little Guy Posted January 21, 2008 Share Posted January 21, 2008 the best way would be to use JavaScript I think but... <?php // This is for Central Standard Time ini_set('date.timezone','America/Chicago'); echo '<p>'.date("g:i A").'</p>'; ?> List of other time zones Quote Link to comment https://forums.phpfreaks.com/topic/86982-change-time-based-on-timezone/#findComment-444793 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.