Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function date_default_timezone_set()


previous

Advertisements

Syntax

bool date_default_timezone_set ( string $timezone_identifier )

Definition and Usage

Sets the default timezone used by all date/time functions in a script.

Paramters

ParameterDescription
timezone_identifierA valid timezone string

Return Value

Returns FALSE if the timezone_identifier isn't valid, or TRUE otherwise.

Example

Following is the usage of this function:

<?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();
   }
?> 

This will produce following result:

Old time zone is America/Denver
New time zone is America/Costa_Rica

previous Printer Friendly

Advertisements


  

Advertisements