Jump to content

Expiration date


davidcriniti

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,

Dave

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/289968-expiration-date/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.