Support

Account

Home Forums Bug Reports Can no longer get raw date field

Solving

Can no longer get raw date field

  • I’m not sure which version this changed in, but I just updated from 5.3.9 to 5.4.2 and noticed the difference.

    I used to call the raw date with:

    `get_field(‘expiry_date’, false, false);

    Which would return something like 20160826

    Since the update, the return format is 2016-08-26

    Changing the return format in the field options doesn’t make any difference, as expected, but you no longer get the raw database data.

    I was using it to compare dates, which no longer works directly unless I replace the dashes from the string.

  • More than likely this coincided with changes needed in relation to the new date/time picker. The dashes are added when the field is loaded. It seems from looking at other code in ACF that if the dashes are not there that the value would get confused with a unix time stamp value. I would suggest adding a load_value filter for date fields, but it you did that ACF would probably convert the value to something other than the date entered.

    It seems that the only choices you have are to remove the dashes after getting the value or to use get_post_meta($post_id, $field_name, true) to get the value.

  • Ah, I didn’t think about using the normal post meta geta.

    I’m fine with the removing slashes as everything is now working for me as it previously was.

    It was more a note that the behaviour has changed, so the documentation might need to be updated here (advanced section) if it is the intended behaviour: https://www.advancedcustomfields.com/resources/date-picker/

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

The topic ‘Can no longer get raw date field’ is closed to new replies.