Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Convert a variable or article custom field to UNIX time equivalent
Say I have a variable or custom field with a value of (for example) 1598356934 – is it possible to convert and show that value as a timestamp, preferably with PHP date() formatting/presentational stuff?
This feels like a job for etc_query but I’m not sure. A task for raw PHP perhaps?
Any pointers very warmly welcomed. Thank you.
Offline
Re: Convert a variable or article custom field to UNIX time equivalent
I’d activate Advanced options pref and enable date function in <txp:evaluate />. Then call (untested)
<txp:evaluate query='date("Y-m-d", <txp:custom_field name="timestamp" escape="integer" />)' />
Offline
Re: Convert a variable or article custom field to UNIX time equivalent
Wonderful – thank you very much, Oleg!
Offline