$timeposted = "7:10pm";
This value is currently Canada time (quebec). I'm trying to find a way to convert it to France's time. How can i do that ?
$timeposted = "7:10pm";
This value is currently Canada time (quebec). I'm trying to find a way to convert it to France's time. How can i do that ?
You can use
date_default_timezone_set
function to change loacal time zoneExample
Assuming that your PHP configuration is set to the Quebec time, you can convert it to France's timezone by doing the following:
Or, if your server is not set to the Quebec timezone you can:
which returns
You can read more about PHP and timezones here: http://www.php.net/manual/en/datetime.settimezone.php
Use the date_default_timezone_set() function of PHP.
If you want to change it to France you would use the
a list of Supported Timezones can be found here: http://www.php.net/manual/en/timezones.php
The functionality of date_default_timezone_set() can be found here: http://php.net/manual/en/function.date-default-timezone-set.php
Check out DateTime::setTimezone:
Example
This is my function that take time from a mysql db (which I've stored entirely in UTC) and converts to a new timezone and formats it simply.
This is a list of supported timezones http://us1.php.net/manual/en/timezones.php