PHP India Time Zone (Get Current Indian time or any Country)

PHP India Time Zone (Get Current Indian time or any Country)

Here you will learn how to get current Indian time by using PHP India time Zone (IST). And after that, you are able to get other countries current time using PHP.

Get current India time using PHP

To get current India time, then first you need to set the default time zone –

<?php
// Asia/Kolkata is for INDIA
date_default_timezone_set('Asia/Kolkata');
?>

After setting the default time zone, Now you are able to get the Current time according to timezone –

Full Code

Get the Current Indian date-time using PHP India time zone (Asia/Kolkata)

<?php
// Asia/Kolkata is for INDIA
date_default_timezone_set('Asia/Kolkata');

// showing current date and time of INDIA;
echo date( 'd-m-Y h:i:s', time ());
?>

But If you want to get the current date-time of other countries, then just change the date_default_timezone_set, like following the example –

<?php
// Asia/Tokyo is for JAPAN
date_default_timezone_set('Asia/Tokyo');

// showing the current date and time of JAPAN;
echo date( 'd-m-Y h:i:s', time ());
?>

Here the list of all the Time Zones that are supported in PHP –

Leave a Reply

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