Ok, here's what I have so far for my expiration date (thanks to Kevin) but
its returning incorrect dates:

function add_to_now($timestamp,
$seconds,$minutes,$hours,$days,$months,$years) {
$mytime =
return $timestamp + $mytime;

$result = mysql_query("SELECT * FROM newsletters_lookup WHERE
aid='$current_user' ORDER BY id");
$num_news = mysql_num_rows($result);

while ($a_row=mysql_fetch_array($result)) {

        $expire_date = add_to_now($date_added, 0, 0, 0, 0, $num_news, $years);
        $expdate = date("F jS, Y g:ia", $expire_date);
        echo $expdate."<br>";

And the results are:

June 1, 1970 1:33am
August 1, 1970 1:33am
October 1, 1970 1:33am

They should be (approximately):

February 23, 1970 1:33am
February 23, 1970 1:33am
February 24, 1970 12:20am

If anyone can spot where the problem is or know of a simpler/more effective
method of determining an expiry date, please let me know.

Thanks a TON!!


> -----Original Message-----
> From: Jason Dulberg [mailto:[EMAIL PROTECTED]]
> Sent: December 26, 2001 6:52 PM
> Subject: expiration date help
> I need to stick a little expiration date into a part of my site but can't
> seem to get it going properly.
> Basically, what I need to do is add 2 months to the number of
> results for a
> particular member. So if someone has 6 entries in the db, they will all
> expire in 8 months.
> I have my $dateadded mysql field is set to DATETIME.
> Can the calculations be made within the mysql query itself? Is it
> a job for
> the DATE_ADD mysql function?
> I would be displaying the expire date in the admin as well as running it
> through an CRON script to do an auto-delete.
> Any suggestions would be awesome! Thanks.
> __________________
> Jason Dulberg
> Extreme MTB
> http://extreme.nas.net

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to