The date_default_timezone_get() function returns the default time zone.
Syntax
date_default_timezone_get(void)
Parameters
void − NA
Return
The date_default_timezone_get() function returns a string.
Example
The following is an example −
<?php echo "Old time zone is ". date_default_timezone_get(); $timeZone = 'America/Costa_Rica'; if( date_default_timezone_set( $timeZone) ){ # Now get this time zone. echo "New time zone is ". date_default_timezone_get(); } ?>
Output
The following is the output −
Old time zone is UTC New time zone is America/Costa_Rica
Example
Let us see another example −
<?php echo date_default_timezone_get(); ?>
Output
The following is the output −
UTC