Hey all, I'm working on a suspension system where a moderator or administrator enters an amount of days for a user to be suspended for. All they do is enter an integer value. This value is the varaible $SuspendTime and would like to add this on to the date but it fails when its like the last day in the month. You will get errors like 37th March etc.. How can this be fixed to automatically go on to next month.
$NewDate = date("j"); $NewDate = $NewDate + $SuspendTime; $DateToEndSuspension = date("F $NewDate, Y @ g:i:s a");
Thanks in advance,
Dj.
$DateToEndSuspension = date("F, j, Y @ g:i:s a", mktime(date("H"), date("i"), date("s"), date("m"), date("d")+$SuspendTime, date("Y")));
\o/
$DateToEndSuspension = strtotime("+$days days");
will get you the Unix timestamp. You could then format the date according to your needs.
If this is for database purposes, note that most DBMS's provide their own date handling, e.g. in MySQL you could do something like 'DATE_ADD(CURDATE(), INTERVAL 30 DAY)'.