Current time and/or Time since Unix epoch in Silver

Hello, currently I’m doing some tests using Silver. Is there a method in Elements RTL or in the Swift base library to get the current time and or the time since the Unix epoch? I can of course just use the version on the backend, but if one of these references can provide me with the function that would be awesome.

thank you!


Elements RTL has a DateTime type that should give you what you need, including UtcNow for the current time and a Ticks and TicksSince1970 properties that should let you work with the unix epoch time, as well.

You can see the full API here:

Marc to the rescue again! Thanks a lot. You have made my few days experience with Elements really great. I definitely plan to stick around, thanks to you and the team!

1 Like

This is interesting, using Ticks provides two results, however using TicksSince1970 always provides the following value: 621355968000000000

Doesn’t matter if I sleep and get it again, or if I build the whole console app again, it is always the same value. Is this a bug or am I wrong in expecting the value to change?

regards and thanks again!

Yes, thats’s a constant, ie the “tick” value for January 1, 1970. 621355968000000000 is the value of ticks from midnight Jan 1 01 CE to midnight Jan 1 1970."

I guess it is maybe named a bit misleadingly; I’ll bring this up for discussion.

Ok I see. Yes, I think maybe it should be TicksUntil1970 or TicksTo1970 since that is what it is actually giving right? So is Ticks giving me the time elapsed since the epoch? Just wanted to verify

Thanks again Marc!!

Yeah, I renamed it.

No, Ticks will give you the ticks since midnight Jan 1 01 CE; you’ll want to subtract TicksSince1970 (now named TicksTill1970, in the next version ;), to get the ticks since the UNIX epoch.