Forum Discussion

CarolineS's avatar
7 years ago

Freemarker "date" to Unix timestamp?

Hi ya'll!

 

I'm attempting to implement a snippet of Javascript code within my community's page wrapper; the snippet requires the user's registration date in 10-digit-timestamp form.

 

I'm able to get user.registrationTime via Freemarker, but this is a string formatted like: "April 9, 2018 12:19:18 PM". Does anyone know how to convert this to a seconds-since-Epoch timestamp? I've searched Google / the Freemarker documentation but haven't found the info I need.

 

Thanks!

- Caroline

 

    • CarolineS's avatar
      CarolineS
      Boss

      Thank you, DolanH!

       

      Unfortunately, this isn't working for me, as the ?long only works on a number, and the date I'm working with appears to just be a string. 

       

      Here's the error, in case you're curious:

      For "?long" left-hand operand: Expected a number, but this has evaluated to a string (wrapper: f.t.SimpleScalar): ==> user.registrationTime [in template "Hitbox" at line 6, column 53]

      I'll keep working on this!