rejetto forum

Unix time

Foggy · 4 · 2019

0 Members and 1 Guest are viewing this topic.

Offline Foggy

  • Tireless poster
  • ****
    • Posts: 806
    • View Profile
I am playing around with a template idea and I am after a way to check two time values to see whether or not something has timed out.

The only way I can think of doing it is with Unix(seconds since 1970) time and taking the original value from the new value and comparing the difference to a predefined timeout value.

Is it possible to have unix time added to the time macro? or perhaps a template symbol for it?

Also after some research into the time macro I have come across the symbol %now% but cant find any explanation. What does it do/what is it for?


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13271
    • View Profile
%now% uses the delphi time format: it's functionally equivalent to the unix time, just numerically different.
but you can use it the same way, to calculate the difference between 2 moments.

while the unix time is integer and 1 is a second, the delphi time is real(with point) and 1 is a day.


{.set|x|%now%.}

do something

{.calc|(%now% - {.^x.})/(24*60*60).} seconds passed

you can even make a user-macro yourself to convert between the 2 formats.
http://www.delphifaq.com/faq/f91.shtml
« Last Edit: December 03, 2019, 11:24:02 PM by Mars »


Offline Foggy

  • Tireless poster
  • ****
    • Posts: 806
    • View Profile
Thankyou Rejetto.

Thats exactly what I wanted to know.


Offline Fysack

  • Tireless poster
  • ****
    • Posts: 644
  • present picture
    • View Profile
    • Admin
 :-* :-* :-* what can i say? The world is my oyster!
GOD CAN READ YOUR MIND