-3

How to find 1 day ago time in PHP microtime() format.

I am trying like this. But still showing the current time.

$date = date("Y-m-d H:i:s", strtotime('-1 day'));
$val = microtime($date);
u_mulder
  • 54,101
  • 5
  • 48
  • 64
Naren
  • 43
  • 8

1 Answers1

1

http://us2.php.net/manual/en/function.microtime.php

microtime() returns the current Unix timestamp with microseconds

You can't use microtime() to get a time from the past, since the funtion only works with current date.

Wouldn't this work for you?

$date = strtotime('-1 day');

Edit: Code corrected according to u_mulder's comment.

Kalko
  • 406
  • 3
  • 11
  • @u_mulder yeah I realized as soon as I read your comment on the question, I didn't realize it at first :D Thank you for noticing ;) – Kalko Sep 20 '16 at 08:59