Ragith Thomas Ragith Thomas - 27 days ago 12
PHP Question

How to get current date and time in php

Thanks in advance. Actually i was using

date('Y-m-d h:i:s', time())
and
date("Y-m-d H:i:s")
to get the current date and time in php but it's not showing the proper time. Instead of showing proper Indian time it's showing some other time
My code is:

$today = date("Y-m-d H:i:s");
echo "Current date and time is ".$today;

Answer

Try this.

date_default_timezone_set('Asia/Kolkata'); 
echo date("Y-m-d H:i:s"); // time in India
Comments