How to change default Timezone in PHP

In PHP, we can set the time zone using the date_default_timezone_set function.

Parameter Description
timezone (Required) Specifies the timezone to set as the default. List of Available Timezones in PHP

Set the default timezone for India

Once we have set the time zone, any date and time functions in PHP script will use the default time zone.The time zone 'Asia/Kolkata' corresponds to the Indian Standard Time (IST).Here's an example of how to use it:

  //Set time zone for India

  //Get default Timezone
  echo date_default_timezone_get();

  //Get the current date and time
  $currentDateTime = date("Y-m-d h:i:s a",time());

  echo "<br>".$currentDateTime;