Setting and getting timezone in PHP

Setting Timezone
In PHP, date_default_timezone_set() is a function that sets the default timezone for all date and time functions in your script. This function takes one parameter which is timezone text, which you want to set for example (e.g., "America/New_York", "Asia/Kolkata").


<?php
date_default_timezone_set('America/New_York');
echo date('Y-m-d H:i:s');
?>
Getting Timezone

In PHP, date_default_timezone_get() is a function that retrieves the current default timezone used by all date and time functions in the script.

<?php
echo date_default_timezone_get();
?>