How to format a custom field of a date which is stored as Unix timestamp (1592235345)

I have a custom field where the data and time is stored as a Unix timestamp, eg. 1592235345. I want to format this to be 15th June 2020. How do I do this in PG? I know the PHP date format method but not within PG.

tiz a built in php function

<?php echo date('m/d/Y H:i:s', 1592235345); ?>

See “timestamp” in

Thanks @mxs. I know about that, it’s how to do it within Pinegrow I’m not sure of. How would I do that?

What type of page are you putting together? Where is the timestamp data coming from?

It’s an archive page for a custom post type created with Toolset. I’m displaying a custom field (date) which Toolset stores as a Unix timestamp.

shouldn’t toolset offer that option on the format?

i mean they say it has “everything you need” :wink:

I know what you mean. However, a custom date field created by Toolset uses the Unix timestamp value instead of yyyy-mm-dd as a standard MySQL date field would. No idea why, but it does. So, when I show that on a page, I need to convert it back to a regular format. This is what I’m struggling with in Pinegrow. I’m sure I’ve achieved this in the past but I just can’t remember how and I’ve looked back through old projects and can’t find it there, either.

When showing a field on a page, I just need to know how I can use PHP to manipulate that field. That’s effectively what I’m after.

you need to embed a php command in your html that will will convert the format to what you want displayed and the echo that to your page as it is served up to the browser. if that toolkit doesn’t offer such functionality, then you will have to dive deeper into server side php than you bargained for.

i don’t know of any client side manipulations that can be done, but i’m sure there’s a js for that.

Thanks @droidgoo. What’s the technique for using PHP within the Pinegrow system? Or should I create a shortcode in the functions file? Seems overkill for what I want.

you open a php command using the tag

<?php // do some commands ?>

but the trick is to tell ur server to parse all your .html as .php code so ti will get picked up.

to you it looks and acts just like .html, but to the server it’s .php with some (a lot :wink: ) of .html tags in it.

you do this by using the .htaccess file you probably already have at your root dir for identifying the path to your 404.html page.

for my server the designation was

AddType x-mapp-php5.5 .html .htm

yours will probably be different

you can find out what the php SERVER_NAME is called by creating a .php file on the server with this php code and then directing your browser to it on the server to see the output.

i relied heavily on this resource and searching stackoverflow a lot (like a lot a lot)

Thanks again @droidgoo but it’s the technique needed in Pinegrow I need a steer on. What Wordpress action should I use to echo a custom field within PHP so I can modify it?

i only have PG Pro, so when i activate the PHP, ASP, ERB extension, all i get is the ability to toggle to php code on/off in the PG live screen area.

maybe that extension does more in PG WP edition?

Aah, the WP actions are completely different.

@matjaz or @Emmanuel , can you steer me in the right direction?

@sitestreet Like this:


Thanks @Emmanuel. How would I use the custom field instead of the static value? I have a field called wpcf-created-date