Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-08-25 12:05:09

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

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

#2 2020-08-25 12:24:29

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

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

#3 2020-08-25 16:50:11

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

Re: Convert a variable or article custom field to UNIX time equivalent

Wonderful – thank you very much, Oleg!

Offline

Board footer

Powered by FluxBB