XF 2.1 Proper use of date_from_format

Cupara

Well-known member
Here is the issue, I have a date format of
Code:
2019-12-24T15:46:23.978Z
and I'm needing to form that into a proper date and time in my XenForo addon. This is being pulled using JSON.

Thanks to @Sim in another thread, we figured out so far the following:
HTML:
{{ date_from_format("Y-m-d\TH:i:s:u\Z", $posts.created_at) }}

Screenshot.png

In the screenshot, there should be a properly formed date and time between the icon and dash but instead I'm left with a blank.

I really want to get this solved so that I can move on to preparing this addon for release.
 
Last edited:
Since there has been no feedback, I guess I'll have to go with the method I wanted to avoid and that inserts the JSON feed to the database while updating the data to a proper unixtime then pulling from the database so it displays correctly.
 
In case anyone else needs this,
the following thread may help :

Basically, the function to change the date format in a template is:
{{ date(date_from_format("Y-m-d", $variable), 'd/m/Y') }}
Y-m-d meaning the php format of the variable (in my case that was the format).
$variable meaning the variable containing the date.
d/m/Y meaning the requested date format.

Good luck :)
 
Back
Top Bottom