TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Get Date Difference in Days between Two Dates
Kannadasan G
May 19
2015
Code
1.1
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
<script type=
"text/javascript"
>
function
daysBetween(startDate, endDate) {
var
millisecondsPerDay = 1000 * 60 * 60 * 24;
var
startDateUTC = Date.UTC(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());
var
endDateUTC = Date.UTC(endDate.getFullYear(), endDate.getMonth(), endDate.getDate());
return
Math.floor((endDateUTC - startDateUTC) / millisecondsPerDay);
}
</script>
JavaScript
Difference in dates