Jump to content

Change Time based on timezone


refiking

Recommended Posts

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

 

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']);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.