Re: [eduran582] Adding days to date field
Hi Eric,
In both MySQL and in the viewers dates are in this format:
2009-07-05 21:05:38
You can convert them to epoch time (seconds since 1970) like this:
$time = strtotime( $myRecord['myDateField'] );
You can add a day to like this:
$time += (60*60*24);
And then convert it back to text like this (see php.net/date for formatting codes):
echo date("D, M jS, Y g:i:s a", $time);
So that's how you do it in PHP. If you're writing a where query for MySQL you can use some MySQL functions though. Here's some examples:
'where' => "publishDate >= NOW()",
'where' => "createdDate >= (NOW() - INTERVAL 1 DAY) ",
'where' => " '2009-07-05 21:05:38' < (myDateField + INTERVAL 1 DAY) ",
Hope that helps!
Dave Edis - Senior Developer
interactivetools.com