Page 2 of 2

Posted: Fri Sep 01, 2006 11:59 pm
by tristanlee85
Alright, so I've got a UNIX date from the database. How do I add say 5 days to a date that's already in the Unix format?

Posted: Sat Sep 02, 2006 12:44 am
by tristanlee85
Basically, I've got a date in the Unix format. I want to test to see if that time is 5 days older than today. So, in rough psuedo:

Code: Select all

if ($stored_date is 5 days older than $today_date)
   {
   echo "old date";
   }
else
   {
   echo "new date";
   }

Posted: Sat Sep 02, 2006 12:49 am
by Christopher
"Unix dates" are in seconds. So five days would be:

60 sec per minute * 60 minutes per hour * 24 hours * 5 days

or

Code: Select all

$numdays = 5;
$new_date = $old_date + (60 * 60 * 24 * $n_days)

Posted: Sat Sep 02, 2006 1:20 am
by tristanlee85
Heh. Ya learn something new everyday. Thank you. I got it to work just fine.