Skip to content
Advertisement

Set start and end date for last 30 days ending today

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

The end date should be today and start date should be today – 30 days.

How can I generate these 2 dates in the above format?

Advertisement

Answer

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'));
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement