How can I best work with GMT? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How can I best work with GMT? (/showthread.php?tid=44323) |
How can I best work with GMT? - El Forum - 08-11-2011 [eluser]gunnarflax[/eluser] If I want users to be able to see the post time on all updates to a site in their own timezone, what do I need to do to achieve that? How will I store the time in the database and how should I load the time? Is Unix timestamps a good way of achieving this? How can I best work with GMT? - El Forum - 08-11-2011 [eluser]toopay[/eluser] You can use any datatype, but it is easier working with integer/Unix timestamps, since to get gmt date, you can instantly write Code: $GMT_date = gmdate('D, d M Y H:i:s \G\M\T', $unix_time)); How can I best work with GMT? - El Forum - 08-12-2011 [eluser]gunnarflax[/eluser] Sweet! thanks! If I want to adjust the time to someone living in a timezone +4 and my server is in +1, should I just add the number of seconds to the $unix_time variable? How can I best work with GMT? - El Forum - 08-12-2011 [eluser]toopay[/eluser] If you want to get the current date and time, based on GMT, you also could use this : Code: $timezone = -5; //(GMT -5:00) EST (U.S. & Canada) How can I best work with GMT? - El Forum - 08-12-2011 [eluser]gunnarflax[/eluser] Thank you very much for your replies, it's exactly what I was looking for! |