Skip to main content
Solved

Epoch Timestamp

  • May 15, 2018
  • 6 replies
  • 379 views

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.
@DateTimeFormat( 19700101000001.234+00:00, %s) = 1.234
@DateTimeFormat( 19700101000001.234, %s) = null
@DateTimeFormat( 19700101000001.234+00:00, %s%z) = null
For unzoned datetime values you could use %Es, however the values will be interpreted as UTC time then.

 

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

david_r
Celebrity
  • 8394 replies
  • 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
  • 4 replies
  • 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.

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
  • 275 replies
  • 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.
@DateTimeFormat( 19700101000001.234+00:00, %s) = 1.234
@DateTimeFormat( 19700101000001.234, %s) = null
@DateTimeFormat( 19700101000001.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
  • 275 replies
  • May 15, 2018
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.
@DateTimeFormat( 19700101000001.234+00:00, %s) = 1.234
@DateTimeFormat( 19700101000001.234, %s) = null
@DateTimeFormat( 19700101000001.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
  • 4 replies
  • 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.
@DateTimeFormat( 19700101000001.234+00:00, %s) = 1.234
@DateTimeFormat( 19700101000001.234, %s) = null
@DateTimeFormat( 19700101000001.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
  • 8394 replies
  • May 17, 2018
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 :-)