Q:

Calculate difference in days between a date pulled from an API and todays today

I am currently trying to figure out how to calculate the difference in days between a date pulled through from an API and today's date.
this is the code I have used to get todays date in the format that matches date from the API:
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();

today = dd + '/' + mm + '/' + yyyy;

This twig code pulls the date of the API through 
{{ job.date }}

What I need to work out to do and struggling with is
today - {{ job.date }} = Difference in Days

I have looked through the articles here but I have struggled to find one that I can understand.
Could this be done with twig?
Any help would be appreciated and even more so if someone could put the snippet together for me.

A:

jQuery approach with help of this post

//split
var todayArr = ('11/03/2019').split('/');
var startDateArr = ('10/03/2019').split('/');

//change format
var today = `${todayArr[2]}-${todayArr[1]}-${todayArr[0]}`
var startDate = `${startDateArr[2]}-${startDateArr[1]}-${startDateArr[0]}`

//calculate
var diff = new Date(Date.parse(today) - Date.parse(startDate));
var days = diff/1000/60/60/24;

console.log(days);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

