Format date custom field from Unix Timestamp

I want to know how I can get a formatted date out of a field that is stored as the number equivalent of the date.

See, In toolset I get a date as “1756339200” (Unix Timestamp). How can I transform this into a proper date formatted as I want to (ie: “Jan 1, 2025”)?

$newDate = wp_date('F j, Y',strtotime($unixTimestamp));

I should’ve been more precise. I want to just format the custom field in the tag, I suspected there was something for it when adding the “date tag” or something like that. ( {{dc:post:meta key=“date-webinar”}} but with something else, any parameter or something)

Ok found the answer but is it documented anywhere? if so could someone please share the doc link?

the result is:

{{dc:post:meta key="custom-field-name" type="date" format="Y-m-d"}}

adding: type="date" format="Y-m-d" is the key here.

1 Like

More info on Dynamic Content formatting here. Have a great day.

I see, I had found that out while testing a bit but something weird happens sometimes.

Here’s the metatag:
{{dc:post:meta key="wpcf-fecha-evento" type="date" }} - {{dc:post:meta key="wpcf-fecha-fin-evento" type="date"}}

The raw values are: “1743552000 - 1743638400”

the date version should be 2025-04-02 - 2025-04-03

Instead I get: https://prnt.sc/p61YUHHNWyNC (nov 20, 2000 - nov 20, 2025)
Now i’m not sure why that is but all the dates are super wrong there. I tried reoving the format and leaving only the “type” as you can see above and the problem remained.

the interesting thing is that with the format, it SOMETIMES got 1 of the 2 dates ok, but there’s always at least 1 that has something wrong. what am i doing wrong here?

Hello @franticape,

Since you are dealing with dates, you will have to add the type and the date format:

{{dc:post:meta key="wpcf-fecha-evento" type="date"  format="Y-m-d" }} - {{dc:post:meta key="wpcf-fecha-fin-evento" type="date" format="Y-m-d"}}

If this does not work, we would be happy to double-check your fields and the return values if we can log in. You can create a secure note in your next reply with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
– Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

image

Best Regards.