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)


which is completely correct.
with date as you use it up there you only generate numerical values in a 
format you specify, and then you substract those numericals from each 
other, echoing the rest of 8876


> But in date thinking it should be 7!


I think if you want to get the number of days you have to

1) substract the  mktime values you used in the date statement to get 
the difference in seconds

2) count how many days you have with this amount of seconds by dividing 
the seconds through 86400

date is a function to give you representations of a date and time at any 
given moment as expressed in unix time in a lot of different, 
configurable formats. after you generated a date representation with 
date, the program doesn't know anything at all about the date/time 
meanings of that string or number.

hth

henning




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