Home Answers Viewqa JavaScriptQuestions javascript date difference in days.

 
 


ratna rathor
javascript date difference in days.
1 Answer(s)      a year ago
Posted in : JavaScript Questions

I want to find the difference between two dates in terms of days. I am using javascript. Please help.

View Answers

May 15, 2012 at 1:31 PM


<html>
<head>
<script type="text/javascript">

var date1=new Date();
var date2 =new Date("Jan, 11, 2000")
var yearDiff=date1.getFullYear()-date2.getFullYear();

var y1=date1.getFullYear();
var y2=date2.getFullYear();;

var monthDiff=(date1.getMonth() + y1*12)-(date2.getMonth() +y2*12);

var day1=date1.getDay();
var day2=date2.getDay();
var dayDiff=(day1-day2) + (monthDiff*30);

document.write("Number of day difference : "+dayDiff);

</script>
</head>
</html>

Description: In javascript whenever you write new Date() it shows the current date in standard format with current day,date,time and GMT.you can also specify your own date by using new Date(). You can get number of years of specified date by using getFullYear() function, number of months by using getMonth() method and number of days by using method getDay(). Now to find date difference in days you must consider years and months too.









Related Pages:
javascript date difference in days.
javascript date difference in days.   I want to find the difference between two dates in terms of days. I am using javascript. Please help.  ... of days by using method getDay(). Now to find date difference
JavaScript Date Difference
JavaScript Date Difference...;Date Difference</h2> <script type="text/javascript"> var...; In this section, we are going to determine the difference between two dates
javascript date difference in years
javascript date difference in years  I want to find the difference between two dates with respect to years. I am using javascript. Please help.  ...=date1.getFullYear()-date2.getFullYear(); document.write("Date difference in years : "+yearDiff
javascript date difference in months
javascript date difference in months  How can I find the difference...; <head> <script type="text/javascript"> var date1=new Date(); var...; Description: In javascript whenever you write new Date() it shows the current date
javascript date comparison
= new Date(); var difference = today - date1; var days =parseInt(difference...javascript date comparison  How to compare dates and display the difference in terms of days?   <html> <head> <script
Javascript calculate number of days between two dates
Javascript calculate number of days between two dates In this tutorial, you will learn how to calculate number of days between two dates.For this, you need to use the Date object  to retrieve the Date's millisecond value
Ask date difference
dates from the user and calculates the date difference in terms of days. import...; }else{ day = curdate - date + noof_days; curmonth = curmonth - 1; } if(cur...Ask date difference  Hello, I have a problem about how to calculate
javascript questions on date
javascript questions on date  how to add some days to an existing date
Date Difference
Date Difference       This example learns how to make the difference between two dates and how... Object class and makes a difference between a Date object and a set of integer
Mysql Date Add Days
Mysql Date Add Days       The Tutorial illustrate an example to add days to the particular days... to add to the specified date. Query:- The below query add the 7 days
Java Swing Date Difference
the following method that calculates the date difference in terms of days...Java Swing Date Difference In this tutorial, you will learn how to find the difference between two dates. Here is an example that accepts two dates from
Mysql Date Minus Days
Mysql Date Minus Days       The Tutorial cover on Mysql Date Minus Days return you the day after... an example from Mysql Date Minus Days. To understand the example, we use the select
PHP Date add days
;days: ".date('l dS \o\f F Y', $date)."... 2009 Date After adding 30 days: Wednesday 23rd of September 2009  ... In this example we will create sample code to add days or weeks
Java subtract days from date
Java subtract days from date In this tutorial, you will learn how to subtract days from date. Using the Calendar class, you can add and subtract date...(-). This will reduce date from date. Here, we are going to subtract few days from
Mysql Date Last 30 Days
Mysql Date Last 30 Days       Mysql is used to find out the last 30 days from current date... days'. To grasp this concept we find out the current date. The Syntax used to find
calculate difference between two dates
calculate difference between two dates  hi, I was actually working on to calculate the number of days between two dates of dd/mm/yyyy format using javascript. can anyone suggest me how to work it outin calculating
What is difference between the java and javascript?
What is difference between the java and javascript?  What is the difference beteen the java and javascript?   Hello Friend, Read Here Thanks
date
date  can u tell me how to calculate difference between a user provided date and the system date in java
date
date  can u tell me how to calculate difference between a user provided date and the system date in java
date
date  i want difference between the date entered in a jtextfield and the system date in java
Difference in two dates - Java Beginners
Difference in two dates  Hello there once again........ Dear Sir... on that. The thing is, that I need to find the difference between the two dates in JAVA...(); Now I want to keep this in my Database...... So after few days
What is difference between the java and javascript?
What is difference between the java and javascript?  What is the difference beteen the java and javascript?   Hello Friend, Difference: 1..., while JavaScript is a scripting language that was introduced by Netscape. 2
javascript date picker - Date Calendar
javascript date picker  how to insert a date picker user control in a html/jsp using javascript??? please help, it's urgent.  Hi Friend, Please visit the following links: http://www.roseindia.net/javascript
Date object using JavaScript
Date object using JavaScript  What's the Date object using JavaScript
javascript tomorrow date.
javascript tomorrow date.  Hi, how can I display tomorrow's date using javascript?   <html> <head> <title>Date after current date</title> <script type="text/javascript"> var mydate= new
Date related query - Date Calendar
Date related query  hi, m a new biginner of java.i m intrested in finding out d difference in d two dates "in terms of number of days "entered by d user using bufferedReader. how can i convert a string into a date object.pls
javascript yesterday date.
javascript yesterday date.  Hi, How can I display the yesterday's... date</title> <script type="text/javascript"> var mydate= new Date...;/head> </html> Description: In javascript whenever you write new Date
javascript current date and time.
javascript current date and time.  How can we display current date and time using javascript?   <html> <head> <title>Current date and time</title> </head> <script type="text/javascript
javascript
javascript  hi, I was actually working on to calculate the number of days between two dates of yyyy-mm-dd format using javascript, and when i click on button then number of days should be display in textbox
Hi .Difference between two Dates - Java Beginners
Hi .Difference between two Dates  Hi Friend.... Thanks for ur Very good response.. Can u plz guide me the following Program.... difference between two dates.. I need to display the number of days by Each Month
JavaScript Validate UK Date
JavaScript Validate UK Date  How to Validate UK Date in JavaScript... if (!validformat.test(input.value)) alert('Invalid Date Format. Please correct.') else{ //Detailed check for valid date ranges var
Change Week Days Format
Change Week Days Format       This Example shows you how to change week days format. In the code given below we are change week days format. Methods used
date format in javascript
date format in javascript  display date format as dd/mm/yyyy and day... help me. thank u var date=/^\d{2}\/\d{2}\/\d{4}$/ if(document.userform.joindate.value.search(date)==-1) { alert("please enter date format as dd/mm/yyyy
Determining the Number of Days in a Month
Determining the Number of Days in a Month   This section will show the way of counting the number of days of a month in the specified year. Following program takes the year as input through the keyboard and shows the number of days
days between two given dates using PHP
;"; // Number of days in between to given date in php $days = (strtotime... days between two given dates using PHP  How can we know the number of days between two given dates using PHP?   Hi friends, Example
JavaScript - JavaScript Tutorial
to set month for the date object.    JavaScript scrollTo...() method of JavaScript when applied to a date object returns an integer value... of a date object.    JavaScript setUTCFullYear method
JavaScript Show Date
JavaScript Show Date..., we are going to display the current date using JavaScript. You can see... Date</h2> <script type="text/javascript"> var date = new
JavaScript parse date
JavaScript parse date..., you will learn how to parse the date in JavaScript. JavaScript provides the function parse() that takes a date in string format and returns the equivalent
SQL Date, SQL Date Examples
of the current month.    Mysql Date Minus Days The Tutorial elaborate an example from Mysql Date Minus Days. To understand...;    Mysql Date Last 30 Days The Tutorial
date_diff
date_diff date_diff alias DateTime::diff returns the difference between two DateTime objects. It returns the difference of two dates, if it exists or return... [, bool $absolute ] ) Parameters datetime - The date to compare
start date and end date validation in javascript - Ajax
start date and end date validation in javascript  hi, i am doing web surfing project. pls guide me for my project. i want start date and end validations in javascript. end date should be greater than start date if so less than
java yesterday - Date Calendar
_date - date + no_of_days; cur_month = cur_month - 1; } if(cur_month... to make date sustract, the result is to make 1 month and 1 day like this, right. now how about 1 year and 1 month? And Can help me to using Date Calender what
Java date add day
Java date add day In this tutorial, you will learn how to add days to date. Sometimes, there is a need to manipulate the date and time (like adding days to date or subtract days from date) for java applications. Here, we are going
Java get number of Days in Month
Java get number of Days in Month   ... of days in the specified month. This example sets the year as 2008, month as Calendar.FEBRUARY and the date as 1 using the method calendar.set(year, month, date
JavaScript Cookies
; function CreateCookie(cookieName,cookieValue,days){ var date=new Date... JavaScript Cookies...; In this section, you will learn cookies in JavaScript. A cookie is a temporary file
Week Days Format Example
Week Days Format Example       This example shows how to format week days using Format class... for formatting and parsing dates. It allows for formatting date into text , parsing text
PHP convert week number to days or month - PHP
PHP convert week number to days or month  Small, simple and easy code that can do following task: 1.Convert Week Numbers to Month 2.Convert Week to Date Generally, we use the date time object in PHP to convert the date
to calculate the difference between two dates in java - Java Beginners
to calculate the difference between two dates in java  to write a function which calculates the difference between 2 different dates 1.The function...(); // Set the date for both of the calendar instance calendar1.set(2007, 12
javascript date validation using regex
javascript date validation using regex  Hi, I want to validate the date using javascript. Please help.   <html> <head> <title>Validating Date format</title> <script type="text/javascript">
On Javascript
number validation, date validation, special character validation, etc

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.