Page 1 of 1

Change the timezone for a script

Posted: Tue Oct 15, 2013 4:28 pm
by mister_v
Hello,

I need to change the timezone to use the correct time with the function date()

Anyone known how to do this?

Re: Change the timezone for a script

Posted: Tue Oct 15, 2013 6:02 pm
by chris
You can use the date_default_timezone_set() function

Code: Select all

date_default_timezone_set('America/Los_Angeles');
print date("Y-m-d");
date_default_timezone_set('Europe/Brussels');
print date("Y-m-d");

Re: Change the timezone for a script

Posted: Tue Oct 15, 2013 8:44 pm
by chris
If you want to set it for all the scripts,
you can set it in php.ini

Code: Select all

[Date]
date.timezone = Your/Timezone