0

I'm pulling a date value (not a datetime value) from a MySQL database, but I need to subtract 30 days from that date, and not sure how to do it. I found a sample using mktime() to break up the day-month-year and subtracting 30 days from the 'day' component, but the result is all wacky. Any help would be appreciated.

2
Contributors
2
Replies
9
Views
6 Years
Discussion Span
Last Post by hielo
0

in php just use strtotime():

echo date('Y-m-d', strtotime("now -30 days") );

In your case INSTEAD of now you would use whatever date you have.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.