Get Current Indian Time In PHP

Get Current Indian Time In PHP

This tutorial is about how to get current Indian time in PHP. There so many options on how to do display the Current Time and date in India.

In order to get the user current timezone, you need to have a javascript. Else, you have to make a default timezone on your pages. For example, you can use “date_default_timezone_set”.

Code to Get Current Indian time in PHP

To begin with, you open a text editor you like. In my case I use SublimeText. Then, create a PHP file. Finally, add the following code and save.

<?php

$Date = date_default_timezone_set('Asia/Kolkata');
echo  "<h3>Your Timezone is Asia/Kolkata</h3>";
//If you want Day,Date with time AM/PM
echo $datetoday = "<b>Date Today: </b>". date("F j, Y, g:i a T") ."</br>";

//To the Current Time 00:00 AM / PM 
echo $datetoday ="<b>Time Today:</b> ". date("g:i a");

?>

 

How to test the PHP code?

To test the PHP code, you have to open a browser. Then, type the “Localhost/currenttime.php” and press enter. After this step, you will be able to see the result just like as shown in the image below.

get current indian time php
get current Indian time PHP

Anyway, if you want to study further about the date in PHP. You visit this tutorial about Unix Timestamp using PHP.

If you have any questions about this topic, please let us know maybe we can help.

Leave a Comment