Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
HTML Pages with CSS and JavaScript
Calculate Number of Days Between Two Days
Chandra Mohan
Ranch Hand
Posts: 63
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
How to calculate number of days between two dates
From date : 01/25/2005 (mm/dd/yyyy)
Todate : 01/29/2005 (mm/dd/yyyy)
Result : 5 months
Thanks in advance.
Regards
ChandraMohan
Thanks and Regards
Chandra Mohan
Eric Pascarello
author
Posts: 15385
6
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
This shows you days:
Date.prototype.DaysBetween = function(){ var intMilDay = 24 * 60 * 60 * 1000; var intMilDif = arguments[0] - this; var intDays = Math.floor(intMilDif/intMilDay); return intDays; } var d1 = new Date("06/10/2005"); var d2 = new Date("06/13/2005"); alert(d1.DaysBetween(d2));
Eric
Eric Pascarello
author
Posts: 15385
6
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Date.prototype.MonthsBetween = function(){ var date1,date2,negPos; if(arguments[0] > this){ date1 = this; date2 = arguments[0]; negPos = 1; } else{ date2 = this; date1 = arguments[0]; negPos = -1; } if(date1.getFullYear() == date2.getFullYear()){ return negPos * (date2.getMonth() - date1.getMonth()); } else{ var mT = 11 - date1.getMonth(); mT += date2.getMonth() + 1; mT += (date2.getFullYear() - date1.getFullYear() - 1) * 12; return negPos * mT; } } var d1 = new Date("06/10/2005"); var d2 = new Date("01/13/2007"); alert(d1.MonthsBetween(d2));
Eric
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
NX: How to solve "48 hours" ?
calcuate days in a calender.era or between two days
No of months between two dates
Calculate Date having DIFFERENT DATE FORMATS
internationalization - date format
More...