Wednesday, September 3, 2008

How to change time zone using php - set default timezone for php

Surely when you develop a site, you need to change current server timezone to a different timezone for client requirements.
You can use date_default_timezone_set() to set default timezone for a given script. You can also edit the php.ini to change the timezone for all projects.

You can find list of supported timezones HERE for the above function

<?php

//before use of date_default_timezone_set

echo date("d-m-Y h:i:s A");

echo '<br /><br />';

//set to US central time
date_default_timezone_set('US/Central');

echo date("d-m-Y h:i:s A");

?>


Get Free Sinhala IT Learning Videos Kuppiya.com

Freelance Jobs

3 comments: