Question

I need to generate two dates in the format YYYY-MM-DD example : 2010-06-09

for the last 30 days so end date is today and start date is today - 30 days

can you help me generate those two dates in the previous format YYYY-MM-DD

thanks folks

Was it helpful?

Solution

for the last 30 days so end date is today and start date is today - 30 days

The strtotime is real friend:

echo date('Y-m-d', strtotime('today - 30 days'));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top