Answered
Timezones in php
I need some advice... obviously..
I have a multi-timezone php site (MySQL) and have been offered lots of ways to approach this.
My current solution is to use a putenv() function in the header to change the timezone environment.
i.e. putenv ("TZ=".$_SESSION['usertimezone']);
This works great when using echo to adjust a timestamp (e.g. Time())
using echo date("D, d-m-Y H:i:s",$whatevertimestamp);
BUT... it gets more complex when entering dates into a database and returning them from it in the correct timezone.
I am sort of aware of the date_default_timezone_set() function but am not clear what the differences are.
I have also heard about the new DateTime($timefield, new DateTimeZone($usertimezone)); function which could convert a date/time field into a timestamp and associate a timezone.
Am I even going in the right direction??????
Any help on this would be very appreciated.
I have a multi-timezone php site (MySQL) and have been offered lots of ways to approach this.
My current solution is to use a putenv() function in the header to change the timezone environment.
i.e. putenv ("TZ=".$_SESSION['usertimezone']);
This works great when using echo to adjust a timestamp (e.g. Time())
using echo date("D, d-m-Y H:i:s",$whatevertimestamp);
BUT... it gets more complex when entering dates into a database and returning them from it in the correct timezone.
I am sort of aware of the date_default_timezone_set() function but am not clear what the differences are.
I have also heard about the new DateTime($timefield, new DateTimeZone($usertimezone)); function which could convert a date/time field into a timestamp and associate a timezone.
Am I even going in the right direction??????
Any help on this would be very appreciated.
