--Mise en fonction de https://www.domoticz.com/wiki/Event_script_examples function gettimedifference (NomDevice) tPreviousUpdate = otherdevices_lastupdate[NomDevice] -- returns a date time like 2013-07-11 17:23:12 year = string.sub(tPreviousUpdate, 1, 4) --logMessage("Cuisine : Year : " .. year) month = string.sub(tPreviousUpdate, 6, 7) day = string.sub(tPreviousUpdate, 9, 10) hour = string.sub(tPreviousUpdate, 12, 13) minutes = string.sub(tPreviousUpdate, 15, 16) seconds = string.sub(tPreviousUpdate, 18, 19) t1 = os.time() t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds} difference = os.difftime (t1, t2) return difference end