Outputting ACF Fields (+ formatting them)

Hi there,

I have a date/time ACF that I want to output like:

{ACF_FIELD type=”date” format=”jS F”} to allow for better formatting.

Can this be done in bricks?

Nah, I think you’d have to make a function to do that. Something like this in your functions.php file:

function prfx_format_date($date,$format) {
    $date = get_field($date);
    return date($format, strtotime($date));
}

And then in bricks you’d do something like this:

{echo:prfx_format_date('ACF_FIELD','jS F')}

Note: this is untested, so let me know if it works. :wink:
Note: This has now been fixed and tested. But I still can’t get commas to work in the format. It’s a confirmed bug that will be fixed at some point. :frowning:

Hey! Thanks for the info.

I ask, because I know other builders can handle this, I appreciate the infancy of Bricks, of course!

I have tried the code…

function prfx_format_date() {

removing “date” from the brackets fixed an error, but the code doesn’t work then.

Thanks for the assistance!

Oops, I patched up my code, I forgot the $ in the function params and when accessing the date variable in the get_field function.

Try the updated function and it should work now. I made it a little fancier for you too. :wink:

I get it though, Bricks doesn’t have everything the other builders have, but what it does have is way better in my opinion. They may add features like this in the future, I dunno.

1 Like

Not accepting commas is now a confirmed bug. :partying_face:

1 Like

Thanks for the code - will give it a try shortly. Really appreciate that, man.

Agree - I am switching to Bricks already! Despite some shortcomings/improvements that are yet to come.

Really believe in this builder!

Hey Embark,

The comma bug I mentioned earlier is now fixed in 1.5.3! :partying_face:

1 Like