Home Forums ACF PRO Need help converting timestamps


Need help converting timestamps

  • I’ve got a development install which I have upgraded to ACF Pro while making a host of other changes and we’ve “lost” our dates in ACF.

    The data is still there in a custom format the we used before (Ex. 2009-10-09), but I am unsure how to convert them all to the correct current format. I know that this can be resolved with a mySQL statement or two, but for the life of me, I’ve been unable to figure it out.

    Any help will be appreciated.

  • Hi @Kracke

    No worries. You can avoid having to modify the DB by adding some code to modify the value when it is loaded from the DB.

    The following code will remove the ‘-‘ from any datepicker values and allow the format to work with ACF PRO.

    add_filter('acf/load_value/type=date_picker', 'my_acf_load_value', 10, 3);
    function my_acf_load_value( $value, $post_id, $field ) {
    	if( strpos($value, '-') !== false ) {
    		$value = str_replace('-', '', $value);
    	return $value;

    Hope that helps

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Need help converting timestamps’ is closed to new replies.