-2

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?

matt.crawfoord
  • 87
  • 1
  • 3
  • 13

3 Answers3

1

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'));
Divyesh Patoriya
  • 518
  • 3
  • 15
-1

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));

Ninja Turtle
  • 1,293
  • 2
  • 24
  • 50
-1

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 :)