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.

I had tried adding the format as well, then tested without but the results were more or less the same, the dates were all wrong.

Hello? could you please help me solve this?

When I output the timestamp I was getting 1764288000 which would be the correct date the date format was outputting. Where are you setting this date? I would double check that.

I had added the credentials for that purpose, so you could see where exactly i was adding it. are you able to see the same in the page I sent? it’s an “event” (single) layout page in cornerstone.

Hey @franticape,

I checked the date format and it looks correct.

I’m sure there’s something wrong, It could be on my end, maybe something on the browser but I highly doubt it.

Look at this page:
https://aladyr.net/eventos-anuales/ciudad-de-mexico-mexico-2026/

Check the dates. they all say 08 dec on my end, when they are all different custom fields, all dates.

please check this out: https://www.loom.com/share/343b37a31c834031adf8fcb3194f4aec

At this point you have access to the site, if you also need access to the cornerstone editor with the page, here it is: https://aladyr.net/cornerstone/edit/35565

Again, please cross-check them with the ones found on the actual event, please!

Hey @franticape,

Try replacing your DC with this {{dc:date:generic date="@{{dc:post:meta key="wpcf-fecha-evento"}}" format="d M Y"}} as it seems to work.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.