Custom date field format

Hello,

I’m trying to fill a custom date field through the REST API using your PHP SDK. This is for an account based in the UK, if that makes a difference.

When I manually fill out the custom date field in the Keap application itself and then query for it using the API, I receive the value as ‘Y-m-d’ (‘2024-09-16’). When I post to Keap using the same API, with the field in the same format, I receive no errors but the field does not get filled on Keap’s end. All other fields in the same request are updated fine and visible in Keap.

I’ve seen a few other threads on this, for example PHP API not updating custom date field? , where the advice amounted to “just try different formats”, but I’ve run out of those without success. I assume there has to be some standard and would be much obliged to receive it.

Thanks.

Welcome @Xander_Teunissen, I have run some tests, and updated the forum post you referenced.

The “Ymd” format works when updating the Custom Date field.

Example what shows updating the Date and Date with Time values.
Note, if you have a Date Time Custom Field, the Time Values are in 15 Minute blocks.

'custom_fields' =>
[
    [
        'id' => 104,  // Custom Field ID Number.
        'content' => date('Ymd', strtotime('2024-07-20')) 
    ],

    [
        'id' => 106,   // Custom Field ID Number.
        'content' => date('Ymd\TH:i:s', strtotime('2024-12-25 18:45:00')) 
    ]     
]

Does that work for you?

2 Likes

Hi @Pav,

Thanks a lot. As it turns out, the date format was not the actual problem I was running into (though the 15 minute block comment is definitely filed away under “things that’ll save me time later”).

When initially testing custom fields, it seemed the content of fields needed to be wrapped in their own array/object to get updated. And this works for all field types, even if they’re just strings… except for the Date fields.

Your solution put me on to that and indeed when using 'content' => date() directly the update goes through without a hitch.

Thanks again.

1 Like