Page 1 of 1
Calculating the time in seconds for a future date
Posted: Tue Mar 31, 2015 5:42 pm
by matgarage
Hi
Is it a way with Livecode to calculate the seconds (the Livecode function) but for a date in the future ?
ex : 29 february 2016, 00:00 h = in seconds from 1/1/1970
Any idea ?

Re: Calculating the time in seconds for a future date
Posted: Tue Mar 31, 2015 5:46 pm
by FourthWorld
put "3/31/15" into tDate
convert tDate to seconds
Re: Calculating the time in seconds for a future date
Posted: Tue Mar 31, 2015 6:47 pm
by matgarage
So simple, so quick, thank you.
I'm going to play

Re: Calculating the time in seconds for a future date
Posted: Tue Mar 31, 2015 7:21 pm
by dunbarx
Midnight on Jan 1, 1970 is the baseLine. But watch out for your timeZone:
Code: Select all
on mouseUp
put 0 into ff
convert ff to dateItems
answer ff
end mouseUp
Unless you are near the Greenwich Observatory, you will get what might seem to be odd information.
Craig Newman
Re: Calculating the time in seconds for a future date
Posted: Tue Mar 31, 2015 8:18 pm
by FourthWorld
The seconds accounts for time zone based on local machine settings. So 0 in GMT is 8 hours earlier than PDT, where I am, and I get "1969,12,31,16,0,0,4", which seems about right.
This makes seconds and internet date two of the most useful formats we have for storing time values, as they both keep track of time all the way down to the second and they both account for time zones. The seconds is more compact, a good choice when storage space is a consideration, and internet date is more human-readable, great for display.
There's also milliseconds for when finer accounting of time is needed, and if you need to account for time even finer there's "the long seconds", which goes down to microseconds.
Re: Calculating the time in seconds for a future date
Posted: Fri Apr 03, 2015 4:31 pm
by matgarage
No problem for me with the time zone, i'm in France.
I suppose that adding or substracting (3600 * x) to the seconds (where x = the GMT+x value) will correct the gap.
Re: Calculating the time in seconds for a future date
Posted: Fri Apr 03, 2015 4:48 pm
by Thierry
matgarage wrote:No problem for me with the time zone, i'm in France.
I suppose that adding or substracting (3600 * x) to the seconds (where x = the GMT+x value) will correct the gap.
As the week-end is coming, you might have 10 mn free for this:
https://www.youtube.com/watch?v=-5wpm-g ... e=youtu.be
Was posted on the user's list by Peter.
Regards,
Thierry