How to set or get default timezone in PHP

In this tutorial, we will explain how to set or get a default timezone in PHP. This will help you to change the default timezone for all date and time in PHP

Using php built-in function date_default_timezone_set() and date_default_timezone_get() we can set and get default timezone respectively.

Timezone in PHP

  • Set default timezone
  • Get default timezone

 

1. Set default timezone in PHP


date_default_timezone_set("America/New_York");
echo date(`H:i:s`);

 

2. Get default timezone in PHP


echo date_default_timezone_get();

31-August 6:50 PM 1515 Views

 Prev question

Next question