Best GMT time configuration by user | PHP

nsan3

New Member
I was wondering how to do the best user configuration when the user sets his own GMT time, e.g. if a user was in the GMT+3 timezone and the user sets it via the UCP.What I've done was, every option in the drop-down menu:\[code\]<select name="timezone"> ... <option value="http://stackoverflow.com/questions/3580584/-7200">GMT-2</option> <option value="http://stackoverflow.com/questions/3580584/-3600">GMT-1</option> <option value="http://stackoverflow.com/questions/3580584/0">GMT</option> <option value="http://stackoverflow.com/questions/3580584/3600">GMT+1</option> <option value="http://stackoverflow.com/questions/3580584/7200">GMT+2</option> ...</select>\[/code\]Like that, and when the user chooses it, it will add the value into his user field in the database.What I'm stuck on is when a post has been created by a user, it uses the time() stamp, and I use the gmdate() function which is this:\[code\]while(loop goes here){ $post_time = $row['post_time'] // e.g. 1282165261 if($row['user_timezone'] > 0) { $timezone = $post_time-$row['user_timezone']; } else { $timezone = $post_time+$row['user_timezone']; }}\[/code\]Which is outputted with this timestamp format:\[code\]gmdate("D jS M Y @ g:iA", $timezone);\[/code\]But the problem is, if I use something below than GMT, e.g. GMT-1, GMT-6, it changes to +The question is, what would be the best way to configure timestamps to the user preferred GMT time?
 
Back
Top