You are here

function bat_date_load in Booking and Availability Management Tools for Drupal 7

Loads a DateTime object from a string.

Parameters

string $date_string: Expects to see a date in the form Y-m-d H:i:s.

Return value

DateTime Object or null if invalid

File

./bat.module, line 723
Provides basic underlying functionality and configuration options used by all BAT modules.

Code

function bat_date_load($date_string) {
  $date_string = check_plain($date_string);
  try {
    $date = new DateTime($date_string);
  } catch (Exception $e) {
    $date = 0;
  }
  return $date;
}