Get the seconds between two times

Verified
Added by iNTERFACEWARE

Use os.ts.difftime() to get the time in seconds between two time, this function allows for time zones and daylight saving

Source Code
   -- Get the time in seconds betwee two two times
   -- NOTE: This function as it allows for time zones and daylight saving.
   
   -- get the difference between the current time and another time
   os.ts.difftime(os.ts.time(), os.ts.time{year=1999, month=12, day=01, hour=22})
Description
Use os.ts.difftime() to get the time in seconds between two time, this function allows for time zones and daylight saving
Usage Details

Use os.ts.difftime() to get the time in seconds between two times. It is important to use this function rather than trying to compare dates directly, because this function allows for time zones and daylight saving.

How to use the snippet:

  • Paste the code into your script

Note: For a more sophisticated handling of date differences see the links below for getting age from a birth date.