PHP API not updating custom date field?

Hi all

So I’m using the PHP API to update various contact details of a certain users (including about 30 custom fields) - everything works apart from one date field which is a custom date field.

$data = array(‘_NEWDateField’ => “3/18/18”,“FirstName” => “Fergz1”);
$infusionsoft->contact( ‘update’, $ifsID, $data );

Using the example above - the FirstName updates no problem but nothing seems to happen
with the date field. I’ve also tried using dashes instead of slashes.

Below is the makeup of the field - Label, Type and DB Name

NEW Date Field Date NEWDateField

Can anyone tell me where I’m going wrong?

Thanks in advance!

Try changing the date format to temporal as in 20180318

1 Like

I updated the date value to the format you mentioned above and the field still remains blank after submission.

Then try a string ‘03-18-2018’. Also, your code snippet would be helpful.

Thanks for your reply! You were correct, I tested a few different date formats, and the correct format was ‘Y-d-m’ ‘2017-09-18’

3 Likes

Hi Aram,

Thank you for pointing out the solution.
I found your suggestion includes 2 options:

  • ‘Y-d-m’
  • ‘2017-09-18’, which is ‘Y-m-d’

Does both of them working for you?

I think it depends on TZ

To follow up on Ming’s question, since I’ve been having this same problem, and after trying pretty much every date format, the correct format to use is Y-m-d. That’s the only one that worked for me

Here is the closing portion of this infinite stupidity.
apparently php assumes your country based on - vs /
if you use / it assumes USA
(dash) lost to auto formatting assumes not USA
str_replace the - to / and then this will work past the 12 th day of the month.
6 hours of my life gone for that. enjoy

Hello,

I am using Y-m-d date format and it is working in my most of the infusionsoft accounts But its not working in one of our user’s infusionsoft account(always blank custom field’s value). I have tried all of the possible date formats but its is not working for me. Can anyone please suggest me what else should I try in this regards
With this data {“FirstName":“Arvinder”,“Email”:"arvinder.kumar@softobiz.com”,“TimeZone”:“Asia/Kolkata”,“_WebinarDate”:“20190611”,“_WebinarDateTimeCombo”:“2019-06-10 16:30:00”} I am sending (although I have changed the date format many )but it acts in a strange way somtimes it will update the webinardate field and sometimes does not ?

When I looked at REST in the past, querying the Date and Time required to be in this format “YYYY-MM-DDTHH:II:SS.000-HH:MM”. The latter “HH:MM” part was a Timezone Offset.

Eg: 2013-10-09T16:15:24.000-07:10

So maybe your could try the following PHP Date Format: “Y-m-d\TH:i:s.000”

If that fails, try: “Y-m-d\TH:i:s.000-00:00”

The reason why it maybe acting strangely is that it tries to work out if you have a valid date or not. Sometimes it will go through depending on the numbers. Either that, or there is bug in the API, or you may have a bug in your code.

@Pav Thanks for the reply I have tried both types but it is not working for me. This is the data I am sending to infusionsoft Array
(
[FirstName] => Arvinder3
[Email] => fgdfgdfg@dghfgh.mh
[TimeZone] => Asia/Kolkata
[_WebinarDate] => 2019-06-13T00:00:00.000
[_WebinarDateTimeCombo] => 2019-06-13 15:00:00
)

Issue only occurs in _WebinarDate field it is of type date. I have tried all possible date formats and datetime formats but some times it updates but in most of the cases it doesn’t update the field value.

This is the code I am using $contactId = $infusionsoftObj->contacts->addWithDupCheck($formattedData, ‘Email’);
$resinf = $infusionsoftObj->contacts->update($contactId, $formattedData);
And in $formattedData I am passing the data as shown above. Any suggestions will be appricated.

Can you double check that the Custom Field Format for the Webinar Date has been set correctly, ie: it is a Date field.

@TomScott should be able answer this one.

@Pav @TomScott Yes, it is Date Field https://screenshots.firefox.com/wR5YYNFbi5vthPE4/mq350.infusionsoft.com

@Arvinder_Kumar1, if you are still stuck, then you can raise an API Support Ticket here: Create a Support Ticket - Keap Developer Portal

Been experimenting with this, and John’s original reply was correct.

It needs to be be in the “Ymd” format.

date('Ymd', strtotime('2024-09-22')) 

If the Date was appearing Blank, then the Date was not correctly set. In Aram’s code example the date is not correct, as the year is set to “18” and not “2018”.