-3

I am running this script to get the difference between two dates but the result comes with decimals. How can I get only the integer? Thank you!

<script type="text/javascript">
var date1 = new Date("01/28/2019"); 
var date2 = new Date(); 
var Difference_In_Time = date2.getTime() - date1.getTime(); 
var Difference_In_Days = Difference_In_Time / (1000 * 3600 * 24); 
document.write(+ Difference_In_Days); 
</script>

The result I get with this code is 752.5539394675926

Entropy
  • 1
  • 1
  • 1
    ParseInt, Math.round, etc. Try to open any JS basic tutorial to check posibilities. – pavel Feb 18 '21 at 12:13
  • 1
    [parseInt(Difference_In_Days)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt) – mplungjan Feb 18 '21 at 12:14
  • 1
    Welcome to Stack Overflow! Please visit the [help], take the [tour] to see what and [ask]. ***>>>[Do some research](https://www.google.com/search?q=javascript+remove+decimals+site:stackoverflow.com)<<]` snippet editor. – mplungjan Feb 18 '21 at 12:15

1 Answers1

1

Use parseInt function:

parseInt(Difference_In_Days);
Arib Yousuf
  • 1,171
  • 1
  • 7
  • 12