0

Hi all,
I'm new to PHP and was wondering if someone could help me...

I need to write something so that when row "expire" (this is the date the account expires) is 5 days from expiring, a message shows up. I can format everything myself, I'm just drawing a blank at how to do this.

Thanks.

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by Smeagel13
0

A basic skeleton ...

<?php

// Assume you have an expiry date stored as a timestamp.
// You've queried the database for the expiry timestamp on the account in question.
// Results have been put into $mysql_account_info using mysql_fetch_assoc().

// Check to see if the time now is equal to or greater than 5 days (in seconds) before the expiry time.
// The use of the word greater in the above sentence means in simple terms,
// the time is in the future or further forward than the expiry time minus 5 days.
if(now() >= ($mysql_account_info['Expiry_Timestamp'] - 60 * 60 * 24 * 5)) {

  echo 'account expiry soon...';

}

?>

You can build up from that, if you have the expiry date stored as a string then you will have to use date functions in PHP such as creating a new date string 5 days in the past with mktime() and date() and plug that into the IF statement.

Edited by Smeagel13: n/a

0

Would NOW() + interval 7 day work?

I think what you're asking is can you put the +7days on the other side, in which case yes you can.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.