SitePoint Sponsor |
|
User Tag List
Results 1 to 9 of 9
-
Nov 1, 2000, 01:06 #1
- Join Date
- Aug 2000
- Location
- Silicon Valley
- Posts
- 2,241
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I am using this:
$dateBetween = date("z",time()) - date("z",$inputTime);
Although I know there will be the problem at the end of a year (1st date will be smaller than the 2nd one).
So how could we get around in this situation?
Great thanks,- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
-
Nov 1, 2000, 10:53 #2
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Try this:
//Subtract the two timestamps
$time = time() - $inputtime;
//Divide by the number of seconds in a day and round off
$numdays = number_format(($time / 86400), 0);
print $numdaysPlease don't PM me with questions.
Use the forums, that is what they are here for.
-
Nov 1, 2000, 12:15 #3
- Join Date
- Aug 2000
- Location
- Silicon Valley
- Posts
- 2,241
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
True. I've thought about that before, but I remember I used floor(). I'll test it again.
Thanks Freddy! (i also have another question about timing, please take a look at it!)
- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
-
Nov 1, 2000, 12:20 #4
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Will do:
Have a look at this though
http://www.php.net/manual/function.floor.phpPlease don't PM me with questions.
Use the forums, that is what they are here for.
-
Nov 1, 2000, 12:31 #5
- Join Date
- Aug 2000
- Location
- Silicon Valley
- Posts
- 2,241
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yes, php.net is my main/wonderful source of getting reference.
So using number_format($somefraction,0) is the same thing as floor($somefraction), am I right?- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
-
Nov 1, 2000, 12:35 #6
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
number_format will round off correctly so 1.7 would be 2 I think floor takes the lower end always. 1.7 would be 1
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Nov 1, 2000, 12:50 #7
- Join Date
- Aug 2000
- Location
- Silicon Valley
- Posts
- 2,241
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Oh, if number_format() does round up (which I believe it is), then I think the code you provided:
$numdays = number_format(($time / 86400), 0);
will have problem:
Test case: $time / 86400 = 0.6 -> returns 1 day -> not today, but yesterday! And the correct return value should be 0.
So the floor should be correct?- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
-
Nov 1, 2000, 12:55 #8
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I guess that would be a matter of prefernece, if it was half way through the day alreay I would count the day, if not I wouldn't.
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Nov 1, 2000, 13:00 #9
- Join Date
- Aug 2000
- Location
- Silicon Valley
- Posts
- 2,241
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
True, since I want to check for the last 7 days, 0-6 will be returned (in compare with today), so I believe using floor will do. Thanks for the discussion!
- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
Bookmarks