Skip to content

Instantly share code, notes, and snippets.

@gwagroves
Created September 2, 2017 05:36
Show Gist options
  • Save gwagroves/7b659bc4b2abef945279d109f4e5399a to your computer and use it in GitHub Desktop.
Save gwagroves/7b659bc4b2abef945279d109f4e5399a to your computer and use it in GitHub Desktop.
Format date to be saved in Drupal.
<?php
/**
* Format a date to be saved in Drupal.
*
* @param string $date
*
* @return string
*/
private function formatDate($date) {
$date_time = \DateTime::createFromFormat('Y-m-d', $date);
return $date_time->format(DATETIME_DATE_STORAGE_FORMAT);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment