Sunday, August 21, 2011

How to set time zone using php?

Here we going to see about how to reset php time zone with out config setting changes.

In php we have two way to reset the time zone.

  • putenv
  • date_default_timezone_set
echo date('y-m-d h:i:s a');
putenv("TZ=America/Chicago");
echo "<br>".date('y-m-d h:i:s a');
date_default_timezone_set('America/New_York');
echo "<br>".date('y-m-d h:i:s a');

Here you can get the list of supported Timezones

No comments:

Post a Comment