Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
ernie.viveiros

Time display in in-line editing box

Hello. I have a question/issue with in-line editing of a time field.

I notice that the default view for in-line editing is 24-hour format, when my preferred format is g:i A. The grid view is correct… it’s the in-line editor view that doesn’t seem to match the time format preferences.

I understand that you are able to input time in g:i A format regardless of the view, but I wonder if you might refer to the time format setting for the initial in-line view.

5 years, 4 months ago
Stefan van den Dungen Gronovius
Developer

Hello,

Can you tell me a bit more for which column you’re trying to change that?
We do have a date time editable, and it can be configurated to use the 12 or 24-hour notation.
For the ACF integration, we already make use if the ACF setting to determine this, but if you’re using another column I could send you a snippet for a hook that alters the behavior for that specific column.

5 years, 4 months ago
ernie.viveiros

Hello Stefan,

This is my problem. I used an ACF time/date field to collect a time/date… but I needed to use a ACF hook to save the date as a Timestamp. I needed to do this to do some date calculations in JetEngine. The tool that I use in JetEngine offers the ability to reformat the timestamp for proper display.

Everything works great, but now this field looks blank in Admin Columns. I wish that we could add some type of function to the Date/Time column to convert the timestamp to a good display format. (The field views with a proper date format in the Meta Box)

Can you help?

Oh… this is the code to save the timestamp. It’s right from the ACF docs…

<?php
add_filter(‘acf/update_value/type=date_time_picker’, ‘my_update_value_date_time_picker’, 10, 3);
function my_update_value_date_time_picker( $value, $post_id, $field ) {
return strtotime($value);
}
?>

Thanks in advance!

~Ernie

5 years, 4 months ago
ernie.viveiros

I’ve solved it…

Basically had to hook into acf/load_value

function acf_load_as_timestamp( $value, $post_id, $field  ) {
    if( $value ) {
        $value = date( 'Y-m-d H:i:s', $value );
    }
    return $value;    
}
add_filter( 'acf/load_value/type=date_time_picker', 'acf_load_as_timestamp', 10, 3 );

This code along with my snippet to save as timestamp will solve the problem. Maybe you can add functionality to recognize timestamps right in the Date/Time columns? In any case, the code here is a good solution.

5 years, 4 months ago
Stefan van den Dungen Gronovius
Developer

Hi Ernie,

Thanks for the input and information. Our ACF integration really expects the ACF date format that ACF is using. That’s the whole purpose of our ACF integration that it works with the default ACF logic.

We also have a Custom Field column that can work with custom fields in general, but as you might expect, working with date formats is always tricky since there are so many formats. And to be honest ACF is not using the most optimal date format. For displaying purposes, the Custom Field column can handle timestamps just fine, but in that case the date editing does not work anymore with ACF, but even that could be manages with one of our editing hooks

https://www.admincolumns.com/documentation/filter-reference/acpeditingvalue/

https://www.admincolumns.com/documentation/filter-reference/acp-editing-save_value/

5 years, 4 months ago

You must be logged in to reply to this topic.