function mailchimp_format_date in Mailchimp 7.5
Same name and namespace in other branches
- 7.4 mailchimp.module \mailchimp_format_date()
Formats a date string before sending to MailChimp's API.
Parameters
string $input: The input date.
Return value
string The formatted date.
See also
http://kb.mailchimp.com/lists/growth/format-guidelines-for-your-import-f...
1 call to mailchimp_format_date()
- mailchimp_mergevars_populate in ./
mailchimp.module - Replace an array of merge field placeholder tokens with their values.
File
- ./
mailchimp.module, line 2065 - Mailchimp module.
Code
function mailchimp_format_date($input) {
// Attempt to convert date string to a timestamp.
// Remove time in standard Drupal date formats. It confuses strtotime().
$date = trim(preg_replace('/(- )?[0-9]+:[0-9]+/', '', $input));
$timestamp = strtotime($date);
if ($timestamp !== FALSE) {
// Return formatted date.
return date('Y-m-d', $timestamp);
}
else {
// Unable to parse the date string.
return NULL;
}
}