I need to subtract two dates and get the number of days that pass from one to another.
I have this code in which I get the fields of the date, so I can put it in any format:
let arrayFechaDesde = AppDelegate().explode(caracter: " ", cadena: fechaDesde)
let arrayFechaDesdeDos = AppDelegate().explode(caracter: " ", cadena: arrayFechaDesde[1])
let dayDesde = arrayFechaDesdeDos[0]
let monthDesde = arrayFechaDesdeDos[1]
let yearDesde = arrayFechaDesdeDos[2]
let arrayFechaHasta = AppDelegate().explode(caracter: " ", cadena: fechaHasta)
let arrayFechaHastaDos = AppDelegate().explode(caracter: " ", cadena: arrayFechaHasta[1])
let dayHasta = arrayFechaHastaDos[0]
let monthHasta = arrayFechaHastaDos[1]
let yearHasta = arrayFechaHastaDos[2]
The variable fechaDesde
and fechaHasta
have this format: 11/10/2016 08:00
How can I subtract both dates to get the number of days that have passed from one to the other?