Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Dates in local time

Tags:

php

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

like image 947
Richard Avatar asked Dec 17 '25 22:12

Richard


2 Answers

date_default_timezone_set("Europe/London");

That will handle the conversion for you for the page.

like image 145
Elle H Avatar answered Dec 20 '25 17:12

Elle H


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

like image 35
William Avatar answered Dec 20 '25 16:12

William