17.04.2022, 13:52
(This post was last modified: 17.04.2022, 13:53 by Erwin van der Zwart.)
Not fully tested but something like this could work (however always tricky with leap years):
Code:
startdate = {
day = 2,
month = 9,
year = 2006
}
enddate = {
day = 16,
month = 4,
year = 2022
}
unixstart = os.time(startdate)
unixend = os.time(enddate)
if unixend < unixstart then
log('Start date is higer then the end date, exiting script')
return
end
seconds = os.difftime(unixend, unixstart)
timediff = os.date('!*t', seconds)
years = timediff.year - 1970
months = timediff.month - 1
days = timediff.day - 1
log(years,months,days)