Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kmsch's avatar
Level 1

PHP date() returns different time than Carbon

Hi guys,

When I run the PHP function date('H:i'), it returns 23:42. However, it's currently 00:42 where I live, one hour later. When I run \Carbon\Carbon::now(), it tells me the correct time of 00:42. I've set my timezone to be Europe/Amsterdam in the /config/app.php.

Can anyone here explain why this happens and what I can do about it? My guess is that it's got something to do with daylight saving time, but I'm not at all sure.

Kind regards, Koen

0 likes
2 replies
TortleWortle's avatar

I'm not sure why it's happening, my guess it's something to do with either the timezone on your device or with the php config files.

You can use the date_default_timezone_set function though like this:

date_default_timezone_set("Europe/Amsterdam");

to set the proper timezone.

1 like
kmsch's avatar
Level 1

The problem seems to have fixed itself. I had already changed the 'UTC' to Europe/Amsterdam, but it didn't work immediately. After about half an hour it's all working fine though.

Thanks for replying TortleWortle :)

Please or to participate in this conversation.