Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: CEST as timezone

Tags:

timezone

php

When calling php in command line with /usr/bin/php, it worries about my timezone settings. I checked with phpinfo() and looked up the php.ini. I would like to use CEST as timezone and wrote;

date.timezone = CEST

Do You see a mistake?

like image 626
ledy Avatar asked Aug 01 '12 14:08

ledy


People also ask

What is PHP time zone?

The default timezone for PHP is UTC regardless of your server's timezone. This is the timezone used by all PHP date/time functions in your scripts.

How can we convert the time zones using PHP?

It's really simple to convert a DateTime from one time zone to another in PHP. Just create a DateTime object using date & time to be converted as the first parameter and the original time zone as the second parameter. Then change the time zone to the desired one using the setTimezone method. That's all!


2 Answers

date.timezone = 'Europe/Berlin';

will give you what you want. As @nickb has mentioned, 'CEST' is not a supported timezone. Also, do not forget the quotes, it has to be a valid string.

like image 95
inVader Avatar answered Oct 21 '22 09:10

inVader


Your problem is that the CEST timezone is not on the list of supported timezones.

You can use CET, which is supported, but I'm not sure how that affects your use case.

date.timezone = "CET"
like image 44
nickb Avatar answered Oct 21 '22 09:10

nickb