问题
I have a date
merge_field that I need to populate in the v3 version of the Mailchimp API. Lots of google searching on this before I found my answer... hopefully this saves someone time.
回答1:
The format expected is: mm/dd/yyyy
.
It appears that single digits in month and day work just fine so don't sweat making it strict. If you're in Javascript passing a date object into this function should work for you (assuming you're okay with using the local timezone):
function mailchimpDateFormat(date) {
return date.getMonth() + 1 + "/" + date.getDate() + "/" + date.getFullYear();
}
So in node.js for example a call to the Mailchimp v3 API would look like this:
mailchimp.put({
"path": "/lists/0564f2d799/members/c5f129f4bac9d1ca985cb58f1f45f24",
"body": {
"email_address": "something@company.com",
"status": "subscribed",
"interests": {
"ca1564ff8f": true
},
"merge_fields": {
"MY_DATE": "4/15/2018"
}
}
}, function (err, response) {
// Do something interesting.
};
来源:https://stackoverflow.com/questions/50848639/mailchimp-api-lists-date-type-parameter-formatting-for-merge-fields