Answer the question
In order to leave comments, you need to log in
How to subtract a friend from one date and get values \u200b\u200bin days?
Good afternoon.
I need to subtract from one date to a friend and get the value in days
Now I use this
$now = new DateTime();
$date = new DateTime("2021-06-01");
$diff = $date->diff($now)->format("%a");
Answer the question
In order to leave comments, you need to log in
First determine which date is newer (by converting to UNIX TIMESTAMP), then subtract the older date from the newer date. Add a minus at the end to the result.
Read about UNIX time, it will immediately become clear to you how to accomplish your task.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question