I have a hosting account on a USA based server. I want to produce an output file with a date/time that is local for me ( in England, UK).
How do I convert the date/time to my local time, and cater for day light saving when appropriate.
thanks
I have a hosting account on a USA based server. I want to produce an output file with a date/time that is local for me ( in England, UK).
How do I convert the date/time to my local time, and cater for day light saving when appropriate.
thanks
date_default_timezone_set() - Sets the default timezone used by all date/time functions in a script
http://www.php.net/manual/en/timezones.php is a list of timezones
If you're using Apache and your host allows .htaccess, you can set it in your .htaccess file and you won't have to add the function on every page. date.timezone
date_default_timezone_set("Europe/London");
That will handle the conversion for you for the page.
In php you can set the environment date format and time zone.
I include this in the header file for all my pages.
putenv('TZ=America/Phoenix');
[date_default_timezone_set][1]('America/Phoenix');
I also execute this SQL statement when I connect so that dates in the db are in the same timezone
SET time_zone = '-7:00';
Arizona doesn't have DST but it can be calculated using timezone_offset_get()
You can check the date and time of a file using getlastmod but I'm fairly sure that even with the environment variable set the file time on the disk will be in local time for the server. If PHP is doing its job well then it will at least be translated into the prescribed "local" time.