You are here

function event_explode_date in Event 5.2

Format datetime string as an array

Parameters

$date datetime string:

Return value

an array containing the event info.

16 calls to event_explode_date()
event_calendar_data in ./event.module
Returns an array of nodes that occur on a given date. Handles content type and taxonomy filters.
event_format_date in ./event.module
Format a date with the given configured format or a custom format string.
event_form_date in ./event.module
Constructs the time select boxes.
event_get_events_event in ./event_database.mysql.inc
event_get_events_event in ./event_database.mysqli.inc

... See full list

File

./event.module, line 2682

Code

function event_explode_date($date) {
  if (function_exists('date_parse')) {
    $date = date_parse($date);
    $return = array();
    $return['year'] = $date['year'];
    $return['month'] = str_pad($date['month'], 2, '0', STR_PAD_LEFT);
    $return['day'] = str_pad($date['day'], 2, '0', STR_PAD_LEFT);
    $return['hour'] = str_pad($date['hour'], 2, '0', STR_PAD_LEFT);
    $return['minute'] = str_pad($date['minute'], 2, '0', STR_PAD_LEFT);
    $return['second'] = str_pad($date['second'], 2, '0', STR_PAD_LEFT);
    return $return;
  }
  else {
    list($date, $time) = explode(' ', $date);

    // make it work for "time only" and "date only" values as well
    if (!isset($time)) {
      if (strpos($date, '-')) {
        $time = '00:00:00';
      }
      else {
        $time = $date;
        $date = '--';
      }
    }
    list($year, $month, $day) = explode('-', $date);
    list($hours, $minutes, $seconds) = explode(':', $time);
    return array(
      'year' => $year,
      'month' => $month,
      'day' => $day,
      'hour' => $hours,
      'minute' => $minutes,
      'second' => $seconds,
    );
  }
}