Forum Discussion

cesarvidril's avatar
11 years ago

Format .now in RFC 3339

Hi

 

I have to make an atom xml, and asked to add the current time in RFC 3339 but i don't know how.

the datetime is "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"

 

Thanks

  • It seems like you forgot to convert your string to date object, convert your string to date using ?datetime("yyyy-MM-dd'T'hh:mm:ss") and then use ?iso_ut on it.

    Let me know if this helps.

7 Replies

  • To be more accurate i use datesupport.now, and i want it to have RFC 3339 format.

  • cesarvidril's avatar
    cesarvidril
    Guide
    11 years ago

    Well i have found that ?iso_utc done it pretty accuratly.

    Now i have another issue, i get a topic with REST API and topic.post_time?iso_utc do an error message (string instead of date).

  • samudhraa's avatar
    samudhraa
    Expert
    11 years ago

    Hi ,

     

    I am assuming , you have the value in date format , and the error is that you have to convert it to string.

    If that's the case ,you can use the following.

    <#assign postDate = topic.date?iso_utc?string />

     

    Also , here is a freemarker date reference built ins , that might be of help.

     

    Hope that helps.

    Thanks,

    Sam

  • cesarvidril's avatar
    cesarvidril
    Guide
    11 years ago

    Tried it.

    "FreeMarker template error: For "?iso_utc" left-hand operand: Expected a date, but this evaluated to a node+sequence+hash+string"

    I have tried to convert it like this ${topic.post_time?datetime("yyyy-MM-dd'T'hh:mmZ")} but get "The string doesn't match the expected date/time format. The string to parse was: "2013-08-22T08:45:35+00:00". The expected format was: "yyyy-MM-dd'T'hh:mmZ"." (tried both z and Z)

  • VarunLuthra's avatar
    VarunLuthra
    Advisor
    11 years ago
    It seems like you forgot to convert your string to date object, convert your string to date using ?datetime("yyyy-MM-dd'T'hh:mm:ss") and then use ?iso_ut on it.

    Let me know if this helps.
  • cesarvidril's avatar
    cesarvidril
    Guide
    11 years ago

    Well i haven't tried without the Z... it worked <_< ... Thanks you good sir :D