Back to Forums








View Full Version : PHP, MySQL, Dates... disaster


Jether
August 30th, 2005, 20:32 PM
Ok, I seen loooodes of threads on this elsewhere but no proper answer:

In a MySQL table there is a date in the format of yyyy-mm-dd. I want to add 30 days onto that. It qould probably be done by PHP, or my a MySQL table. But remember you must take into account the amount of days in each month etc. Its a hard problem to solve and as far as I've seen PHP or SQL dosn't have any functions to do it directly. Has anyone got any help at all?

Curio
September 4th, 2005, 12:28 PM
I for one can't tell what you are asking. May be a reason why you have no replies. Are you saying the date was entered wrongly?

petard
September 4th, 2005, 14:21 PM
Just add 30 days worth in seconds:
30 days = 2, 592 ,000 seconds
Theres a mySQL function to do that.

Jether
September 4th, 2005, 14:31 PM
oh right, I couldn't find anything like that when I looked before but ill have another search later

cleve
September 10th, 2006, 11:55 AM
$newdate = mktime(0, 0, 0, date("m") , date("d")+30, date("Y")); could solve your problem.

:D