Saturday, April 20, 2024

How to get date difference in days with jquery?

How to get date difference in days with jquery?

Hello, welcome to In this post, I will tell you How to get date difference in days with jquery? I personally like jquery very much. Most of my code is full with jquery. When I stuck in php or other language then that stuckness I remove with jquery code.

Here is the working code and you need add this into your jquery script:

var depDateFull = $(‘.departureDate’).val();
var retDateFull = $(‘.returnDate’).val();
var sdt = new Date(depDateFull);
var rdt = new Date(retDateFull);
var diff = new Date(rdt – sdt);
var days = diff/1000/60/60/24;
alert(days);//you will difference in days

There are so many jquery code and css tricks and i will let you know all. Please do comment if you any query related to this post. Thank you.

the authortherichpost
Hello to all. Welcome to Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

1 Comment

  • //Date diff perfectly
    var end = new Date($(“#endDailyDate”).val());
    var start = new Date();
    var diff = new Date(end – start);
    var days = diff/1000/60/60/24;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.