Return the difference between $time1 - $time2 in seconds

time:diff_in_seconds(STRING $time1, STRING $time2) : INT

time:diff_in_seconds("2020-1-1 10:31 UTC","2020-1-1 10:30 UTC")
#=> 60

# note: if $time1 is less than $time2 the return value is going to be negative
time:diff_in_seconds("2020-1-1 10:30 UTC", "2020-1-1 10:31 UTC")
#=> -60

# note: if two dates are equal then the return value is 0
time:diff_in_seconds("2020-1-1 10:30 UTC", "2020-1-1 10:30 UTC")
#=> 0

# One year worth of difference in seconds
time:diff_in_seconds("2021-1-1 10:30 UTC", "2020-1-1 10:30 UTC")
#=> 31622400

# note: two dates with different timezones could be equal even when the hour/minutes/day is different
time:diff_in_seconds("2020-1-1 10:31 UTC","2020-01-01 02:31:00.000000 PST")
#=> 0

Copyright ©2013-2022 SunSed®. All rights reserved.