Site logo

[Resolved] Convert timestamp from custom field type

Home Forums Support [Resolved] Convert timestamp from custom field type

Home Forums Support Convert timestamp from custom field type

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2586880
    Kim

    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.

    #2586902
    David
    Staff
    Customer Support

    Hi there,

    just had a look at the Toolset Date field:

    https://toolset.com/documentation/customizing-sites-using-php/functions/#date

    If you expand the + More it has some How to use this field with: Shortcodes including one for a formatted date eg.

    [types field="wpcf-date-time-start" format="Y/m/d g:i:s A"][/types]

    Try adding shortcode inside a Headline block.

    #2587006
    Kim

    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!

    #2587032
    David
    Staff
    Customer Support

    Glad to be of help.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.