Solved

How do I get Unix Epoch Time?

  • 13 February 2024
  • 2 replies
  • 28 views

Userlevel 5
Badge +1

In PHP I can use ‘U’ format. How do I do this in Arc Script?

So far I’ve got

 

<arc:set attr="expiry">[utcnow() | dateadd('day', 7) | todate('U')]</arc:set>

 

But ‘U’ is not recognised, and I get

Error:

Formatter todate failed in the evaluation of [utcnow()|dateadd('day', 7)|todate('U')]. The error was:Input string was not in a correct format.Value: 2024-02-20T11:07:09+00:00Parameters: U

icon

Best answer by russell-jerseypost 13 February 2024, 12:26

View original

2 replies

Userlevel 5
Badge +1

OKay, I figured it out

<arc:set attr="expiry">[utcnow('U')|dateadd('day', 7)|datediff('second', '1970-01-01')]</arc:set>
 

Userlevel 6
Badge

There is also a “unix” formatter to the now expression:

 

[now(unix)]

 

This will return the time as epoch

Reply