I want to get current date and time in certain format . and current timestamp minus 15 minutes in certain format .
How do I do this in PHP?
I want to get current date and time in certain format . and current timestamp minus 15 minutes in certain format .
How do I do this in PHP?
Please try following code :
echo "current time: " .date('Y-m-d h:i:s');
echo "<br>current timestamp minus 15 minutes :". date('Y-m-d H:i:s', strtotime('-15 minutes'));
You could get current datetime using php date() function, for your format you could use following code -
date("Y-m-d H:i:s")
for current time stamp minus 15 minutes you could use time() function -echo time() - (15 * 60)
to get exact time of minus 15 minutes in datetime format you could use this code - echo date("Y-m-d H:i:s", time() - (15 * 60));
Current time: date_default_timezone_set('Australia/Melbourne'); $date = date('m-d-Y h:i:s a', time());
-minus 15 minutes: echo date('m-d-Y h:i:s', strtotime('-15 minutes'));
Try and google next time :)