For PHP's data and time functions, see this page:
    http://www.php.net/manual/en/html/ref.datetime.html

You didn't mention a database - are you going to be selecting
records in a database based on a date?

I haven't seen this anywhere in the documentation, but my
favorite way of doing date math, and the way I've seen other
people do it also, is to convert your dates to unix timestamps -
that is, convert each date to the number of seconds since 1970,
then subtract or add, then convert the result back into a date.

   $today_seconds = time(); // get current unix timestamp
   $num_days = 5;

   $num_days_seconds = (60*60*24*$num_days);
   $date_before_seconds = $today_seconds - $num_days_seconds;
   
   // now convert new date seconds back into a date
   $date_before = date("m-d-Y", $date_before_seconds);


Or use this that I found in the "date" documentation:

$five_days_ago_seconds = mktime (0,0,0,date("m"),date("d")-5,date("Y"));
$date_5_days_ago = date("m-d-Y", $five_days_ago_seconds);


HTH.

-- 
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com

Matthew Ley [[EMAIL PROTECTED]] wrote:
> I am working on a project where I need a function that will take the current
> date and subtract however many days off of it a client specifies.  Would
> anybody know a way I can set this up?  I pretty new at this so my vocabulary
> is very basic.
> 
> 
> -- 
> PHP General 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]

-- 
PHP General 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