PHP returning wrong date

PHP returning wrong date

From time to time we are working on small campaigns, where competition starts at given time. Because in Australia we have “so many” timezones, it’s critical to set things correctly according to the time zone.

So first thing first, let’s check a server time zone:

date
Wed Dec 12 18:46:11 AEDT 2018

Unfortunately, PHP turns something completely different:

$today = date('YmdHi');
var_dump($today);
string(12) "201812120746"

The date is a little bit offset. After digging out, PHP also needs timezone setup correctly, either in php.ini:

date.timezone =

Or using:

date_default_timezone_set('UTC');