Jump to content

Expiration date


Recommended Posts

Hi everyone,


My googling seems to have found an way to add x days to the current date, and I'm sure that finding x days from a date pulled from my database must be pretty similar, but I just can't seem to get it working.


My task involves teachers setting notifications which are displayed for a number of days designated by the teacher.


So when the teacher creates the notiication, the `notificatin_date` field is updated with the timestamp.  The `notification_duration` field is an integer between 1 and 21.


I can get this info out of the database without problem:

$notification_set  = date('Y-m-d', strtotime($notification['notification_date']));
			   $notification_duration = $notification['notification_duration'];
			   echo $notification_duration . "<br/>";
			     echo  $notification_set . "<br/>";

However, when I try and add the duration to the date when the notification was set, to echo the expiry date, I run in to problems. This is what I've got at the current time, but I'm obviously not 'adding' $notification_duration and $notification_set correctly in the first line below, which is causing all my problems. Any help is much appreciated.

	$expiration_date = $notification_set + strtotime($notification_duration . "days");
			   if ($expiration_date> date)
				echo "Your notification will expire on ";   
			   else if ($expiration_date < date)
				echo "Your notification expired on ";   
			   else echo "Your notification expires today ";
			   echo   date('jS', strtotime($expiration_date));
			echo " of ";
	echo date('F', strtotime($expiration_date));
				echo ", ";
	echo date('Y', strtotime($expiration_date));   

Thanks for your time,







Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.