Date helper - Human to unix with timezone support - 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: Date helper - Human to unix with timezone support (/showthread.php?tid=43390) |
Date helper - Human to unix with timezone support - El Forum - 07-09-2011 [eluser]Philo01[/eluser] I'm currently working on a project where all time is stored in GMT. I allow users to schedule an event using their local time. I noticed that if you are using the human to unix function it will actually convert the given time and date to GMT. This is not very handy for example: You schedule an event at (local UP1 + Daylight saving) 09/07/11 10:00:00 PM it will save this as 1310248800. But if you to convert this back to the users local time using the gmt_to_local function you will notice that the time has shifted 2 hours 10/07/11 00:00:00 AM. It's easy to solve luckily, create a new file inside application/helpers/MY_date_helper.php Code: /** This will store the time correctly using GMT Would be great is this could be integrated into CI by default. Date helper - Human to unix with timezone support - El Forum - 07-09-2011 [eluser]adityamenon[/eluser] Consider sending a commit on BitBucket. The CI main developers will decide whether or not to accept your code... |