View Single Post
Old 12-05-2012, 12:27 PM   PM User | #7
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by mh_and;1297413days;[/CODE

is the modulus good way of replacing parseInt here? .
No. You have been given two scripts - both work, but julien007's is slicker. Don't ask for help and then ignore it.

var d = Math.floor(days+11/12);

11/12 of a day is (24-2) = 22 hours, so if you add 11/12 to the value of days (say 2.09) you get 3.00666666. Math.floor then resolves to 3 (days).
Likewise if days = 2.08 adding 11/12 gives 2.9966666, which resolves to 2 days.

That is what you asked for.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Users who have thanked Philip M for this post:
mh_and (12-05-2012)