PHP

GET & SET TIMEZONE IN PHP

SET DEFAULT TIMEZONE IN PHP.INI date.timezone = "Asia/Bangkok"

PHP DEFAULT TIMEZONE

01

GET SYSTEM TIMEZONE IN SCRIPTS echo date_default_timezone_get();

SET SYSTEM TIMEZONE IN SCRIPTS date_default_timezone_set ("Asia/Tokyo");

THIS USES SYSTEM TIMEZONE $dt = new DateTime("2019-08-07 06:00:00"); echo $dt->getTimezone()->getName(); echo $dt->format("d/M/Y H:i:s O");

TO SET A TIMEZONE $dt = new DateTime("2019-08-07 06:00:00", new DateTimeZone ("Asia/Tokyo"));

DATE TIME OBJECT TIMEZONE

02

TO CHANGE TIMEZONE $dt->setTimezone(new DateTimeZone  ("Antarctica/Troll")); echo $dt->getTimezone()->getName(); echo $dt->format("d/M/Y H:i:s O");

DATE TIME OBJECT TIMEZONE

03