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.

Nevermind. I think I got it.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.