Jquery get difference between two dates in days example

In this tutorial im going to learn how to get difference between two dates using jquery. Using below example i can calculate difference dates in days in jquery, we can get simply difference between two dates in jquery

Example :-

<!DOCTYPE html>
<html>
<head>
    <title>get difference between two dates in days using jQuery</title>
</head>
<body>
  
<script type="text/javascript">

	var days1 = daysdifference('10/11/2023', '10/25/2023');
	
	console.log(days1);
  
  
function daysdifference(firstDate, secondDate){
    var startDay = new Date(firstDate);
    var endDay = new Date(secondDate);
   
    var millisBetween = startDay.getTime() - endDay.getTime();
    var days = millisBetween / (1000 * 3600 * 24);
   
    return Math.round(Math.abs(days));
}
</script>
   
</body>
</html>

Output :-

Hi I am Amit Kumar Thakur Experienced as s Software Developer with a demonstrated history of working in the information technology and services industry. Skilled in HTML, CSS, Bootstrap4, PHP, Laravel-9 , REST API,FB API,Google API, Youtube Api, Bitbucket,Github,Linux and jQuery. Strong engineering professional focused in Computer/Information Technology Administration and Management. Currently my profile is to Software Developer, analyze the requirement, creating frame for web application, coding and maintenance.

Related Posts

How to remove fake path from url in laravel ?

In this tutorial we’re going to learn how to remove fake path from url in laravel using javascript. Now fakepath removing successfully form url 👍

List of My Blogs Written from May to October 2023

List of My Blogs Written in May 2023 1 How to Show Notification using Sweet Alert in Laravel 9 2 How to use Soft Delete and Restore…

How to Convert Array to Object in Javascript?

What is Array Object ? JavaScript, arrays are a special type of object used for storing and manipulating lists of values. Despite their name, arrays in JavaScript…

What is Model ? Object Model in JavaScript ?

What is Model ? A model is a representation of a real-world entity or concept. It can be used to describe the structure and behavior of the…

How to print Null value Using JavaScript ?

In JavaScript, if you want to print the string “null” when a variable is null, you can do so add in !== operator. Benefits of Using if-else…

How to use Prompt function in JavaScript ?

In this tutorial we’re going to learn how to use Prompt function using JavaScript. Just use below code and put put inside the script tag Output:- I…

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x