Forum Moderators: coopster
I am using the following to store the date when a user registers on my site and determine the date / time 12 months ahead of the registered date.
[php]
# Get the current server time
$now = time();
# Determine the expiry date '365 days'
$days2expire = 365;
# timestamp of expiry date
$expirystamp = strtotime('+' . $days2expire . ' days', $now);
# make it human readable
$expiry_date = date("Y/m/d @ H:i:s", $expirystamp); // example output 2008/08/08 @ 06:54:15
$date_registered = date("d-m-Y H:i:a", $expirystamp); // example output 08-08-2008 06:54:am
[/php]
I will need to write code to update a record in the DB to 'expired' if the expiry_date is past the current date.
Am I best to store the date in the DB like so using ($expiry_date & $date_registered)?
[php]
date_registered DATETIME NOT NULL default '0000-00-00 00:00:00',
date_12_months_ahead DATETIME NOT NULL default '0000-00-00 00:00:00',
[/php]
Or should I be using timestamps and a different type of table?
Any advice would be greatly appreciated :)