I am trying to save the current date and time and i have used the following code
Current PHP version: 5.4.16
date_default_timezone_set('Asia/Kolkata');
$datet = date("Y-m-d H:i:s ");
When i echo it the output will be
2017-04-25 05:07:17
But actual time what i need is
2017-04-25 10:45:17
I have tried using now()
but its also showing the same date rather than the current time, In what ways i can get the Current date and time. Any help appreciated.
have you tried to change the server time, print date on console, if this mismatched, then change the server time.
This gives you correct time after setting default time zone "Asia/Kolkata"
date_default_timezone_set("Asia/Kolkata");
echo date("Y-m-d h:i:s");
Please check my attachment. Here, First of all I have check echo date_default_timezone_get();` and getting my default timezone Asia/Calcutta and after that when I changed timezone as
date_default_timezone_set("Asia/Bangkok");
echo date_default_timezone_get();
Asia/Bangkok