Author Topic: A (simpler) timestamp function  (Read 501 times)

0 Members and 1 Guest are viewing this topic.

Offline luke

  • QB64 Developer
  • Seasoned Forum Regular
  • Posts: 285
A (simpler) timestamp function
« on: August 30, 2019, 09:07:32 AM »
Steve has a function here that generates a timestamp based on the Unix timestamp, seconds since 1/1/1970. However, it's rather... complex, and doesn't take into account the silliness that is daylight saving.

Here's a simpler one. Works on both Windows & Linux, returns the Unix timestamp.

Code: [Select]
DECLARE LIBRARY
    FUNCTION time& (BYVAL null&)
END DECLARE

PRINT timestamp

FUNCTION timestamp&
    timestamp& = time&(0)
END FUNCTION
« Last Edit: August 30, 2019, 09:08:34 AM by luke »

Offline bplus

  • Forum Resident
  • Posts: 7129
  • b = b + ...
Re: A (simpler) timestamp function
« Reply #1 on: August 30, 2019, 09:31:40 AM »
Hi Luke,

Can you do different date+time conversions to seconds?

Offline luke

  • QB64 Developer
  • Seasoned Forum Regular
  • Posts: 285
Re: A (simpler) timestamp function
« Reply #2 on: August 30, 2019, 09:39:19 AM »
If you want to map these to actual datetimes, go use Steve's function.

This is for if you need a reliable counter like TIMER that doesn't suffer from wrap-around, daylight saving, timezones etc.