Speed up development with full-stack environments for every branch.

Learn More

How to get and set default timezone [PHP and date]

1898 Runs 17398 Views 7544 Copies
Saved

Saved

dipesh.parmar 55

dipesh.parmar
published 4 years ago

<div style="margin-left:50px;">
<?
  echo "<h2>date_default_timezone_get()</h2>";
  echo "This function returns the default timezone used by all date/time functions in the script.";
  
  echo "<hr/> <h3>Example</h3>";
  echo date_default_timezone_get();
  
  echo "<hr/>";
  
  echo "<h2>date_default_timezone_set()</h2>";
  echo "This function sets the default timezone used by all date/time functions in the script.";
  /*
     in below code we are setting default timezone for this script to Asia/Calcutta.
  */
  date_default_timezone_set("Asia/Calcutta");
  echo ' Using <strong>date_default_timezone_set("Asia/Calcutta")</strong> we can set timezone.';
  echo "<hr/> <h3>Get Setted Default Timezone</h3>";
  echo date_default_timezone_get();
?>
<p>
   for different timezone refer
   <a href="http://www.php.net/manual/en/timezones.php" target="_blank">PHP TimeZone</a>
</p>
</div>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).