Mailchimp date validate problem - ISO8601 rejected
Asked Answered
M

4

8

I am trying to use Mailchimp.com's API 3.0 to add people from a PHP web server, but my datetime values for "timestamp_signup"and "timestamp_opt" are being rejected on insert subscriber.

According to this page : https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/ the format of timestamp_signup and timestamp_opt is ISO 8601 format and both are writeable.

But all the versions I have tried have been rejected: "2018-10-19T13:50:37+01:00"
"2018-10-19T13:50:37" "2018-10-19T13:50" "2018-10-19"

Many thanks Ian What is the correct format?

Mary answered 19/10, 2018 at 13:41 Comment(0)
E
8

Great find Ian, that seems to be a new issue within the MailChimp API that occurred first with us around a week ago, but it seems to also not happen always.

I contacted the MailChimp Support and they confirmed it seems to be a problem on their end and that they will look into it.

For now I can confirm that your workaround (YYYY-MM-DD HH:MM:SS) works fine but it is not what the MailChimp API states and should definitely be fixed by them.

Eparch answered 19/10, 2018 at 15:42 Comment(2)
Good to know. IMO the API should either require the time-zone, or the documentation should warn which zone is assumed (UTC?) if none given. Hmm - backwards compatibility will need some thought!Mary
Mailchimp must support "php date('c');" format. According to php.net/manual/en/function.date.php 'c' means ISO 8601 date.Tomtit
M
4

The format to use is YYYY-MM-DD HH:MM:SS

Not ISO 8601 which is YYYY-MM-DDTHH:MM:SS+HH:MM

Mailchimp.com's software generated correct ISO8601 dates when it sends datetimes back. However it requires the "T" to be a space, and will reject a date that includes the timezone (the +HH:MM on the end).

This is contrary to my reading of the standard.

Mary answered 19/10, 2018 at 13:45 Comment(1)
Note - the time is taken as belonging to UTC, but most programs will give you local time. If you are not running under UTC/GMT then you will get back a datetime with a time-zone that is some hours out. Convert to UTC before sending the time in.Mary
E
1

@Ian is correct. The right format is not ISO 8601 but the classic one:

YYYY-MM-DD HH:MM:ss

Be careful if you're using JS/NodeJS with momentJS for instance. The right format is the following:

moment().format("YYYY-MM-DD HH:MM:ss")

The seconds are in lower case. Otherwise, you will have the fractional value which results in an error on the Mailchimp side.

Eri answered 18/1, 2022 at 15:21 Comment(0)
X
0

For me the main issue was the missing support for milliseconds

Xanthic answered 28/8 at 14:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.