You are here

function date_mktime in Date 6

Same name and namespace in other branches
  1. 5.2 date_php4/date_php4.inc \date_mktime()
  2. 5 date.inc \date_mktime()
  3. 6.2 date_php4/date_php4.inc \date_mktime()

Return a timestamp given a local time. Originally by jackbbs.

Parameters

$is_gmt: whether the timestamp is a GMT date that should not have a timezone conversion applied.

$test: whether the date functions are being tested, used to force the low level function even for current dates.

2 calls to date_mktime()
DatePHP4LibTest::testPHP4DateLibrary in tests/date_test.test
date_gmmktime in date_php4/date_php4.inc
Like date_mktime with no GMT conversion.

File

date_php4/date_php4.inc, line 895

Code

function date_mktime($hr, $min, $sec, $mon = false, $day = false, $year = false, $is_gmt = false, $test = true) {
  $hr = intval($hr);
  $min = intval($min);
  $sec = intval($sec);
  if (!$test) {
    if ($mon === false) {
      return $is_gmt ? @gmmktime($hr, $min, $sec) : @mktime($hr, $min, $sec);
    }
    $mon = intval($mon) > 0 ? intval($mon) : 1;
    $day = intval($day) > 0 ? intval($day) : 1;
    $year = intval($year);

    // Below PHP 5.2 for windows, we don't check 1970 because with timezone
    // differences, 1 Jan 1970 could generate negative timestamp
    if (variable_get('date_php_min_year', 1970) < $year && $year < 2038) {
      return $is_gmt ? @gmmktime($hr, $min, $sec, $mon, $day, $year, 0) : @mktime($hr, $min, $sec, $mon, $day, $year, 0);
    }
  }
  $mon = intval($mon) > 0 ? intval($mon) : 1;
  $day = intval($day) > 0 ? intval($day) : 1;
  $year = intval($year);
  include_once './' . drupal_get_path('module', 'date_php4') . '/date_php4_lib.inc';
  return _date_mktime($hr, $min, $sec, $mon, $day, $year, $is_gmt);
}