[PHP] Re: counting with dates (help!)

2002-01-21 Thread Ken Gregg

Another macro language I used had a newdate function. Pass it a data and an
offset in number of days and it would return the new date. I duplicated it
in php here:

function newdate( $strdate, $ndays)
{
# strtotime doesn't like dashes
  $strdate = str_replace(-,/,$strdate);
  $temp = strtotime($strdate);
  $n = $ndays * 24 * 60 * 60;
  $n2 = $temp + $n;
  return( date(Y-m-d, $n2 ));
#  return(date(m/d/Y, $n2 ));
}


Ken Gregg
Enhanced Data Systems, Inc.
http://www.rwre.com for the best in Southwest Oregon Real Estate


Sander Peters wrote:

 Hello,

 This is my problem:

 $today = date(Ymd, mktime(0,0,0, date(m),date(d),date(Y)));
 $last_week = date(Ymd, mktime(0,0,0, date(m),date(d)-7,date(Y)));
 echo ($today - $last_week);
 The result is a number like 8876 (20020107-20011231 = 8876)
 But in date thinking it should be 7!

 How can I let php count in real days/month/years in stead of numbers?

 Maybe this is a silly question, but anyone who has the answer would help
 me very much!

 Thanks in advance!

 --
 Met vriendelijke groet / With Greetings,

 Sander Peters

site: http://www.visionnet.nl/
   email: mailto:[EMAIL PROTECTED]
 webmail: mailto:[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]


[PHP] Re: counting with dates (help!)

2002-01-07 Thread George Nicolae

$today=mktime(0,0,0,date(m),date(d),date(Y));
$last_week=mktime(0,0,0,date(m,mktime(0,0,0,date(m),date(d)-7,date(Y
))),date(d,mktime(0,0,0,date(m),date(d)-7,date(Y))),date(Y,mktime(
0,0,0,date(m),date(d)-7,date(Y;
echo date(d,$today)-date(d,$last_week);

--


Best regards,
George Nicolae
IT Manager
___
X-Playin - Professional Web Design
www.x-playin.f2s.com



Sander Peters [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hello,


 This is my problem:

 $today = date(Ymd, mktime(0,0,0, date(m),date(d),date(Y)));
 $last_week = date(Ymd, mktime(0,0,0, date(m),date(d)-7,date(Y)));
 echo ($today - $last_week);
 The result is a number like 8876 (20020107-20011231 = 8876)
 But in date thinking it should be 7!

 How can I let php count in real days/month/years in stead of numbers?

 Maybe this is a silly question, but anyone who has the answer would help
 me very much!

 Thanks in advance!


 --
 Met vriendelijke groet / With Greetings,

 Sander Peters

site: http://www.visionnet.nl/
   email: mailto:[EMAIL PROTECTED]
 webmail: mailto:[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]