XF 2.0 Format timestamp within JS

Template magic:

HTML:
{{ date_time($timestamp) }}
{{ date($timestamp) }}
{{ time($timestamp) }}

Take a look at XF\Tempate\Templater for a full list of template functions and filters you can apply.
 
Whoops, I messed up above.I have a UNIX timestamp, 1527562156, and I want to either format it to e.g. 29.05.2018 04:49 or place it into a <xf:date> tag (not xf:time) which would render to a HTML <time> tag with pre-set data-values.
<xf:date time="{$xf.time}" /> =>
HTML:
<time class="u-dt" dir="auto" datetime="2018-05-29T03:53:50+0100" data-time="1527562430" data-date-string="May 29, 2018" data-time-string="3:53 AM" title="May 29, 2018 at 3:53 AM">1 minute ago</time>
I know the first one can be done via hacky JS, so I'm looking for a clean solution. And, yea, unless there's a possibility to render templates from JS, template magic won't work for me :D
 
Back
Top Bottom