Site logo

Archived topic

Convert timestamp from custom field type

3 replies · Started by Kim on March 29, 2023

Viewing posts 1–4 of 4

Hi there,

I am trying to create an archive page from a custom content type (Events) that has some custom field types (like: wpcf-date-time-start).

For this I am creating an element as described in https://docs.generatepress.com/article/block-element-content-template/

I managed to get the value from the date-time-start custom field in a Headline block by following this tutorial: https://www.youtube.com/watch?v=Ff7ikQ7Yw0w

But the value is a timestamp like "1680220800". Is there a way I can convert this to a readable date?

I'm not sure if it's relevant but I'm creating custom post types and fields with Toolset.

Also, I have created an archive-event.php template in a child theme.

Thansk for your fast reply David!

If I paste the short code in a Headline block it will automatically change into a paragraph block. That's ok I guess, I don't really need it to be a headline.

The shortcode did not work initially but changing it to [types field="date-time-start" format="Y/m/d g:i:s A"][/types] did to thrick. (Removed "wpcf-" from the field value).

Thanks!

Glad to be of help.

This archived topic is closed to new replies.