Forum Discussion

mkuehnkhoros's avatar
5 years ago

Epoch Format for current_revision.last_edit_time Not Date-Formattable?

Hello,

If I execute the following LiQL query in the API Browser:

 

SELECT post_time, current_revision.last_edit_time FROM messages LIMIT 1

 

I get the following (abbreviated here) result, which is as I expect, everything looks great: 

 

{
  "data" : {
    "items" : [ {
      "post_time" : "2019-11-22T13:06:18.863-08:00",
      "current_revision" : {
        "last_edit_time" : "2019-11-22T13:06:18.863-08:00"
      }
    } ]
  }
}

 

But in my component, when I use this code to format/display those date/time values:

 

<p>Created ${result.post_time?date} / Last edited ${result.current_revision.last_edit_time?date}</p>

 

The post_time value renders correctly, but for current_revision.last_edit_time, I get the following error:

 

_TemplateModelException:The string doesn't match the expected date/time/date-time format. The string to parse was: "1574456778863". The expected format was: "MMM d, yyyy".
The nested reason given follows:
Unparseable date: "1574456778863"

 

This value seems to be a Unix timestamp (epoch) since that value maps to "Friday, November 22, 2019 9:06:18.863 PM" which matches the "last_edit_time" in my original query.

My questions are:

  • why does the API Browser show a date/time value when my component call to restadmin("2.0","/search?q="... to run the same query returns a timestamp
  • can I format a timestamp like this somehow
  • is this a bug of some sort

Any help would be appreciated.

Thanks,
Matthew

2 Replies