Forum Discussion
gutovanzin
5 years agoFrequent Visitor
Get current time in UNIX timestamp
Hello! I created a blank Query that returns the current date and time in ISO format. = DateTimeZone.SwitchZone(DateTimeZone.LocalNow(),-3,0)
Returns: 2021-01-13T16:03:28.8506372-03:00 Is i...
- 5 years ago
Try this gutovanzin
= Duration.TotalSeconds(DateTime.LocalNow() - #datetime(1970,1,1,0,0,0))It simply gives you the total seconds from Jan 1, 1970 at midnight through now. Replace my DateTime.LocalNow() with your DateTimeZone.SwitchZone() function and it will work just fine.
You can round that with Number.Round if you don't need all of the decimals.
Anonymous
4 years agoNot applicable
If you are looking for a formula to the the current UTC Epoch Time, try this:
= Number.Round(Duration.TotalSeconds(DateTimeZone.UtcNow() - DateTimeZone.FromText("1970-01-01T00:00:00Z")))
If you need the value in millisecond UTC Epoch Time, use this:
= Number.Round(Duration.TotalSeconds(DateTimeZone.UtcNow() - DateTimeZone.FromText("1970-01-01T00:00:00Z")) * 1000)