1

I am writing a program in php.

Normally we use set_default_timzone() to set the time zone .

I have details of many users in my database and based on that i am trying to select the time zone for the user like

If user has chosen GMT + 5.30 at the time of registration ,I wanted to set default time zone as ('Asia/Kolkata') for his profile page

So i am looking for a way so that i could set the time zone for user based on the time zone whatever he had provided .

I am adding some more text Here

I have data like GMT + 5.30 in my db based on this i wanted to set the time zone like

if (timezone == "GMT + 5.30 "){
   set_default_timezone('Asia/Kolkata');
} 

Above code is logic only

Another one

$offset = -5;
$timezone = getTimeZone($offset); //return America/New_York 
user1667633
  • 4,449
  • 2
  • 16
  • 21
  • 1
    use [`date_timezone_set`](http://www.php.net/manual/en/datetime.settimezone.php) to set the date in the required timezone. `(PHP 5 >= 5.2.0)` – air4x Oct 10 '12 at 10:30
  • I think solution you can find here: http://stackoverflow.com/questions/1091372/getting-the-clients-timezone-in-javascript – Mantas Vaitkūnas Oct 10 '12 at 10:30

1 Answers1

-3

Please refer this.It may help you

I'd recommend using server timezone or UTC, rather than storing different data for each user. This way, your database will be fully consistent, and you can perform some operations like comparisons without having to, for each entry, fetch the *user_timezone* column and perform the conversion (which is not fully free)

Pravitha V
  • 3,308
  • 4
  • 33
  • 51