You are here

function calendar_user_date in Calendar 5

Returns a local timestamp (as defined by the user or site's timezone) for midnight GMT.

Return value

integer timestamp

8 calls to calendar_user_date()
calendar_filter_day in ./calendar.module
Callback for day filter. Build year, month, day, min, and max into query object.
calendar_filter_month in ./calendar.module
Callback for month filter. Build year, month, day, min, and max into query object.
calendar_filter_week in ./calendar.module
Callback for week filter. Build year, month, day, min, and max into query object.
calendar_filter_year in ./calendar.module
Callback for year filter. Build year, month, day, min, and max into query object.
calendar_get_calendar in ./calendar_api.inc
Adapted from event_get_calendar() function in the event module Reworked to remove dependency on event module

... See full list

File

./calendar_api.inc, line 344

Code

function calendar_user_date($part = 'timestamp') {
  global $user;
  static $date;
  calendar_load_date_api();
  if (!$date) {
    $now = date_time();
    $date = date_gmmktime(array(
      'mon' => date_format_date('m', $now),
      'mday' => date_format_date('j', $now),
      'year' => date_format_date('Y', $now),
    ));
  }
  switch ($part) {
    case 'year':
      return date_format_date('Y', $date);
    case 'month':
      return date_format_date('m', $date);
    case 'day':
      return date_format_date('j', $date);
    case 'hour':
      return date_format_date('H', $date);
    case 'minute':
      return date_format_date('i', $date);
    case 'week':
      return date_format_date('W', $date);
    default:
      return $date;
  }
}