-2

I found this:

$minutes = (strtotime("2012-09-21 12:12:22") - time()) / 60;

In this question

But the string from the API that I took is like 06-09-19 | 16:23:17 and this code don't work at all.

How can I do?

Thanks.

renguer0
  • 17
  • 10
  • `(DateTime::createFromFormat('d-m-y \| H:i:s', '06-09-19 | 16:23:17')->format('U') - time()) / 60;` – splash58 Sep 06 '19 at 19:53

1 Answers1

0

You'll need to manually parse that date format as it is non-standard using DateTime::createFromFormat:

$date = DateTime::createFromFormat('d-m-y \| H:i:s', '06-09-19 | 16:23:17');
$minutes =  ( $date->format('U')-time() ) / 60;
cOle2
  • 4,725
  • 1
  • 24
  • 26