Skip to main content
Solved

How do I get Unix Epoch Time?

  • February 13, 2024
  • 2 replies
  • 75 views

Forum|alt.badge.img+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

Best answer by russell-jerseypost

OKay, I figured it out

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

This topic has been closed for replies.

2 replies

Forum|alt.badge.img+1

OKay, I figured it out

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


James B
Forum|alt.badge.img
  • Employee
  • February 13, 2024

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

 

[now(unix)]

 

This will return the time as epoch