--- Marian Briones <[EMAIL PROTECTED]> wrote:
> Thanks for the zip code stuff - I'm going to give that first solution
> a shot. Keeping it simple at this moment!
>
> Now the next thing, I am writing a script that will run as a cron job
> to delete records from a table that are more than 14 days old. The
> entry date is just the good old date field in this format 2005-06-27
> that goes in when the record is made using NOW().
>
> How can I make my script do a date calculation? I could either put an
> exp date in the data table when the record goes in,but how do I say
> that the exp date is NOW() + 14 (days?) NOt sure about calculations
> with date and time.
Since you are dealing with dates well after 1 Jan 1970 (epoch date for Unix)
and the DB is probably on the same machine as Apache, you can use PHP's
functions for date calculations.
The strtotime() function is rather interesting. It will accept many date
format strings and return an integer number of seconds since the epoch date.
$now = strtotime("now");
$then = strtotime("now +14 days");
print "$now: " . date("Y-m-d H:i:s", $now) . "<br>\n";
print "$then: " . date("Y-m-d H:i:s", $then) . "<br>\n";
You could also use MySQL's DATE_ADD() function for an interval such as you
describe.
James
_____
James D. Keeline
http://www.Keeline.com http://www.Keeline.com/articles
http://Stratemeyer.org http://www.Keeline.com/TSCollection
http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
Summer Semester Begins Jun 20 -- New Classes Start Every Few Weeks.
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/