Calculate difference between dates until minutes javascript!

3

I have the following date in an input: 25/09/2016 11:20:00 for example. I need to calculate the difference for the current date and return at least until the minutes. Can be in jquery or javascript. How do I do it?

    
asked by anonymous 27.09.2016 / 16:19

1 answer

7

Have you tried using momentjs ?

link

Its usability is quite simple look some ex:

<script type="text/javascript" src="moment.js"></script>
<script type="text/javascript">
        var data1 = moment('19/08/2013 01:00', "DD/MM/YYYY hh:mm");
        var data2 = moment('18/08/2013 21:00', "DD/MM/YYYY hh:mm");
        var diferenca = data1.diff(data2, 'hours');

        console.log(diferenca); // 4
 </script>


<script type="text/javascript" src="moment.js"></script>
<script type="text/javascript">
        var data1 = moment('19/08/2013 01:00', "DD/MM/YYYY hh:mm");
        var data2 = moment('18/08/2013 21:00', "DD/MM/YYYY hh:mm");
        var diferenca = data1.diff(data2, 'days');

        console.log(diferenca);
</script>

In case after you do the diff data you have to do a parse just read from the page of the moment that has several good examples with what you need.

    
27.09.2016 / 16:27