Change Timezone in PHP
DateTimeZone is the representation of time zone. You can change the timezone using this function. For example, If you want Indian time zone, use “Asia/Kolkata”.
1 2 3 | $dtz = new DateTimeZone("Asia/Kolkata"); //Your timezone $now = new DateTime(date("Y-m-d"), $dtz); echo $now->format("Y-m-d H:i:s"); |
This link will give you a list of time zones. http://www.php.net//manual/en/timezones.php Use this function date_default_timezone_get() to know the default timezone of your server.
1 2 | $timezone = date_default_timezone_get(); echo "The current server timezone is: " . $timezone; |
OUTPUT: The current server timezone is: Europe/Paris