Forum Discussion

Calvin's avatar
Calvin
Contributor
12 years ago

How to convert REST API time string to datetime

Hi there,

 

I want to filter messages by time period.

Which more specifically, are the message ids returned by /ratings/key/forum_topic_metoo/ratings/leaderboard

This API seems not receiving max_age parameter as the Kudos APIs, so I have to filter them by my own.

 

Then I have the problem below:

The REST API returns time strings like  2013-06-21T06:29:10+00:00,

And the <#assign time1 = "2013-06-21T06:29:10+00:00"?datetime("yyyy-MM-dd'T'HH:mm:ssZ")/> causes error.

I've tried datetime("yyyy-MM-dd'T'HH:mm:ss'+00:00'"), but that was just ignoring the timezone, having the converted datetime uncomparable to ${.now}.

Anybody helps.

 

 Calvin

  • Hey Calvin,

     

    As of release 13.2 we have support to parse string to ISO date format. You need something like this

     

    <#assign my_date = datesupport.parseAsIso8601("2012-12-10T03:52:06+00:00") />

     Hope this helps.

     

    Regards,
    Chhama

     

  • Hey Calvin,

     

    As of release 13.2 we have support to parse string to ISO date format. You need something like this

     

    <#assign my_date = datesupport.parseAsIso8601("2012-12-10T03:52:06+00:00") />

     Hope this helps.

     

    Regards,
    Chhama