I'm getting timestamps off by about 1 hour.
x&& = ExtendedTimer
y&& = epoch
l1
= INSTR(l
+ 1, d$
, "-") SELECT CASE i
'Add the number of days for each previous month passed CASE 1: d
= d
'January doestn't have any carry over days. CASE 2, 4, 6, 8, 9, 11: d
= d
+ 31 CASE 5, 7, 10, 12: d
= d
+ 30 d = d + 365
IF m
> 2 THEN d
= d
+ 1 'add an extra day for leap year every 4 years, starting in 1970 d = d - 1 'for year 2000
s~&& = d * 24 * 60 * 60 'Seconds are days * 24 hours * 60 minutes * 60 seconds
ExtendedTimer##
= (s~&&
+ TIMER)
'--get days passed since 1-1-1970--
total_past_days = year_day_count + leap_year_days
total_past_sec = total_past_days * 86400
'--get days so far in month--------
mc(1) = 31
mc(2) = 28
mc(3) = 31
mc(4) = 30
mc(5) = 31
mc(6) = 30
mc(7) = 31
mc(8) = 31
mc(9) = 30
mc(10) = 31
mc(11) = 30
mc(12) = 31
'--get days past to month start----
x = x + 1
day_count = day_count + mc(x)
current_month_sec = day_count * 86400
month_time_sec = month_days * 86400
'--get current seconds in day------
day_time_sec = hours + mins + sec
epoch = total_past_sec + month_time_sec + current_month_sec + day_time_sec
(ExtendedTimer can be found in the sample area here on the forums:
https://www.qb64.org/forum/index.php?topic=1598.0 )
Checking the timestamps against the website here, your values appear to be off by about an hour:
https://www.epochconverter.com/Looking at the code, is this intentional? hours = (VAL(LEFT$(TIME$, 2)) - 1) * 3600
It seems as if you're subtracting an hour from the timer intentionally? If this is for a timezone localization, you might want to make a note of that in your post and make it a variable which another user could set to adjust for their own timezone as needed.