Set Default Time Zone

Some of you may have faced the issue for converting timezone for displaying date and time.

Means suppose you want to display current time in India, than what will you do for that.

You might have added 5 hours and 30 minutes to the default time.

But there is already a functionality for that in PHP.

You can switch the timezone as per your requirement.

For example,

You get default time by

 <?php echo date(’D , F j, Y, h:i:s A’); ?> 

For getting time in India

Just write this

<?php date_default_timezone_set(’Asia/Kolkata’); ?> 

And now you get Indian time by

<?php echo date(’D , F j, Y, h:i:s A’); ?> 

I am attaching a simple example.


Time Zone.txt

1) Download the file and save the text file as PHP file.

2) Place the file in your root directory.

3) Execute the file from browser.

Further information can be found at : timezone info

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top