2
In PHP I wanted to fetch the first day and the last day of the last 7 days. I have the current date:
$data_actula = date("Y-m-d");
Now I want to get the date 7 days ago. For example, today is day 2014-07-29, I want to find the value 2014-07-22. With this I have to always keep in mind the changes of the months. How can I reach this value?
That’s right. Thank you very much!
– pc_oc
Although suitable to the example, without being boring, I advise the use of Datetime and Dateinterval objects if there are comparison calculations.
– neoprofit
@neoprofit, I agree with what you said and at'e I find it interesting to have an answer that covers the
DateTime
but I thought because the question was asked usingdate()
that the PO would like the answer while maintaining the type.– Mansueli
@Kyllopardiun you’re right!
– neoprofit
I think no delay and pr[opria Datetime will come to consider the kind of argument that strtotime() accepts.
– Bruno Augusto