Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

date_default_timezone_set("Europe/London") does not return correct time

When I use following code to get current London time, it gives the wrong time.

At the time of testing the current London time was 02:11:16 PM, Wednesday 01, June 2011, but I using the following code:

date_default_timezone_set('Europe/London');
echo date('m/d/y h:i a', time());

Gave me: 06/02/11 02:12 am

Why did it not return correct London time?

like image 446
user739393 Avatar asked Jun 01 '11 13:06

user739393


People also ask

How to set default time zone in php?

The date_default_timezone_set() function sets the default timezone used by all date/time functions in the script.

What timezone does PHP use?

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.


2 Answers

date_default_timezone_set("Europe/London");

try with double quotes. works on godaddy

like image 174
Michal - wereda-net Avatar answered Oct 14 '22 10:10

Michal - wereda-net


Check your ini file whether timezone is set or not,

ini_set('date.timezone', 'Europe/London');

Try this it should work.

like image 23
Arun Kumar Avatar answered Oct 14 '22 10:10

Arun Kumar