find difference between two dates in angularjs


AngularJS is one of the greatest frameworks which a web developer must need to learn. It has many advantages. It is very easy to learn because there are lots of tutorials available on the internet. Today I am going to share a tutorial with you guys. This tutorial will help you to find "Difference Between Two Dates". I am writing this tutorial here because many of my friends asked for this on my Facebook Page.

Steps to Get Difference Between Two Dates: 

Here I am going to share the code which shows day count of a specified date to current date. For this, We have to create a javascript code which provides the current date. The code which I shared will help to get it. 
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
if(mm<10) {
today = yyyy+'/'+mm+'/'+dd;
Now we need to input two dates. The above code will give us the current date and we need to put another date. The code to get the difference between two dates are given below.
var date2 = new Date(today);
var date1 = new Date(date);
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
$scope.dayDifference = Math.ceil(timeDiff / (1000 * 3600 * 24));
return $scope.dayDifference;
On the above code, The date1 and date2 are representing the date. and it will compare by $scope.dayDifference. Then finally, it will return the result by using the return $scope.dayDifference.

An output of The Above Code:

You can use the script for many of your AngularJS Applications. I used this code for my Asset Tagging Web Applications and for my Warranty Web Application.

Interesting Article for Web Masters:

I hope you well enjoyed this article. If you have any doubts that related to this article. Please let me know by using my FB page or by using the comment box that given below. Thanks


  1. Expected to form you a next to no word to thank you once more with respect to the decent recommendations you've contributed here. We are providing AngularJs training in velachery.
    For more details:AngularJs training in velchery

  2. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition. We are providing AngularJs training in velachery.
    For more details: AngularJs training in Velachery


Wapmaster or Webmaster can Comment Us with the following Comment Box . Don't add Links to your site for Spamming our Blog .. Once you add Comment with Link . It will be deleted immediatly by our Admins .