Skip to main content
Solved

Epoch Timestamp


I'm just trying to get an epoch timestamp. I have a Creator>Attribute Creator>Inspector. I'm using @DateTimeFormat(@DateTimeNow(),%s) but am getting null returned. All other formats work. What would cause this?

Seems like I'm having an issue with epoch time. I'm seeing the same results (null values or rejected features) in other transformers as well, such as the DateTimeFormater. I have tried converting both ways, from and to epoch. Interestingly the 'preview' in the transformer always works. My '%s' format is also auto-recognized as epoch too.

Best answer by lenaatsafe

Hi @rqf4v9

 

please take a look at %s description in Date/Time Functions > Format String Flags and Examples > @DateTimeFormat. The doc states:

 

Accepts zoned datetime. Outputs epoch time.
@DateTimeFormat19700101000001.234+00:00%s) = 1.234
@DateTimeFormat19700101000001.234%s) = null
@DateTimeFormat19700101000001.234+00:00%s%z) = null
For unzoned datetime values you could use %Es, however the values will be interpreted as UTC time then.

 

 

View original
Did this help you find an answer to your question?

6 replies

david_r
Celebrity
  • May 15, 2018

It seems like the epoch format requires the time zone, try this:

@Evaluate(@DateTimeFormat(@DateTimeNow(local),%s))

Also look at the @DateTimeFormat documentation, where it specifically says that %s is rejected for regular datetimes.


  • Author
  • May 15, 2018
david_r wrote:

It seems like the epoch format requires the time zone, try this:

@Evaluate(@DateTimeFormat(@DateTimeNow(local),%s))

Also look at the @DateTimeFormat documentation, where it specifically says that %s is rejected for regular datetimes.

Thanks David. You're right, it needed a defined zone. Works great now.

 

I've read the documentation but can you clarify (or point me to) "%s is rejected for regular datetimes"? I don't see that part and understand what it means.  

 

 

 


Forum|alt.badge.img
  • Best Answer
  • May 15, 2018
Hi @rqf4v9

 

please take a look at %s description in Date/Time Functions > Format String Flags and Examples > @DateTimeFormat. The doc states:

 

Accepts zoned datetime. Outputs epoch time.
@DateTimeFormat19700101000001.234+00:00%s) = 1.234
@DateTimeFormat19700101000001.234%s) = null
@DateTimeFormat19700101000001.234+00:00%s%z) = null
For unzoned datetime values you could use %Es, however the values will be interpreted as UTC time then.

 

 


Forum|alt.badge.img
rqf4v9 wrote:
Thanks David. You're right, it needed a defined zone. Works great now.

 

I've read the documentation but can you clarify (or point me to) "%s is rejected for regular datetimes"? I don't see that part and understand what it means.  

 

 

 

Hi @rqf4v9

 

please take a look at %s description in Date/Time Functions > Format String Flags and Examples > @DateTimeFormat. The doc states:

 

Accepts zoned datetime. Outputs epoch time.
@DateTimeFormat19700101000001.234+00:00%s) = 1.234
@DateTimeFormat19700101000001.234%s) = null
@DateTimeFormat19700101000001.234+00:00%s%z) = null
For unzoned datetime values you could use %Es, however the values will be interpreted as UTC time then.

 

 


  • Author
  • May 15, 2018
lenaatsafe wrote:
Hi @rqf4v9

 

please take a look at %s description in Date/Time Functions > Format String Flags and Examples > @DateTimeFormat. The doc states:

 

Accepts zoned datetime. Outputs epoch time.
@DateTimeFormat19700101000001.234+00:00%s) = 1.234
@DateTimeFormat19700101000001.234%s) = null
@DateTimeFormat19700101000001.234+00:00%s%z) = null
For unzoned datetime values you could use %Es, however the values will be interpreted as UTC time then.

 

 

 

Ah, I see. Thank you.

david_r
Celebrity
  • May 17, 2018
rqf4v9 wrote:
Thanks David. You're right, it needed a defined zone. Works great now.

 

I've read the documentation but can you clarify (or point me to) "%s is rejected for regular datetimes"? I don't see that part and understand what it means.

 

 

 

I agree it's not easy to find and it's worded a bit strange... You have to scroll down almost half the page an expand the "@DateTimeFormat" header, where it's documented near the of that section.

 

My interpretation of that phrase is that %s is rejected as a format flag if the input is a regular datetime, as opposed to a datetime with timezone. Feel free to suggest that Safe make this clearer :-)

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings