本文整理汇总了PHP中adodb_get_gmt_diff函数的典型用法代码示例。如果您正苦于以下问题:PHP adodb_get_gmt_diff函数的具体用法?PHP adodb_get_gmt_diff怎么用?PHP adodb_get_gmt_diff使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了adodb_get_gmt_diff函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: adodb_mktime
/**
Return a timestamp given a local time. Originally by jackbbs.
Note that $is_dst is not implemented and is ignored.
*/
function adodb_mktime($hr, $min, $sec, $mon, $day, $year, $is_dst = false, $is_gmt = false)
{
if (!defined('ADODB_TEST_DATES')) {
// for windows, we don't check 1970 because with timezone differences,
// 1 Jan 1970 could generate negative timestamp, which is illegal
if (!defined('ADODB_NO_NEGATIVE_TS') || $year >= 1971) {
if (1901 < $year && $year < 2038) {
return @mktime($hr, $min, $sec, $mon, $day, $year);
}
}
}
$gmt_different = $is_gmt ? 0 : adodb_get_gmt_diff();
$hr = intval($hr);
$min = intval($min);
$sec = intval($sec);
$mon = intval($mon);
$day = intval($day);
$year = intval($year);
$year = adodb_year_digit_check($year);
if ($mon > 12) {
$y = floor($mon / 12);
$year += $y;
$mon -= $y * 12;
}
$_day_power = 86400;
$_hour_power = 3600;
$_min_power = 60;
$_month_table_normal = array("", 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$_month_table_leaf = array("", 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$_total_date = 0;
if ($year >= 1970) {
for ($a = 1970; $a <= $year; $a++) {
$leaf = _adodb_is_leap_year($a);
if ($leaf == true) {
$loop_table = $_month_table_leaf;
$_add_date = 366;
} else {
$loop_table = $_month_table_normal;
$_add_date = 365;
}
if ($a < $year) {
$_total_date += $_add_date;
} else {
for ($b = 1; $b < $mon; $b++) {
$_total_date += $loop_table[$b];
}
}
}
$_total_date += $day - 1;
$ret = $_total_date * $_day_power + $hr * $_hour_power + $min * $_min_power + $sec + $gmt_different;
} else {
for ($a = 1969; $a >= $year; $a--) {
$leaf = _adodb_is_leap_year($a);
if ($leaf == true) {
$loop_table = $_month_table_leaf;
$_add_date = 366;
} else {
$loop_table = $_month_table_normal;
$_add_date = 365;
}
if ($a > $year) {
$_total_date += $_add_date;
} else {
for ($b = 12; $b > $mon; $b--) {
$_total_date += $loop_table[$b];
}
}
}
$_total_date += $loop_table[$mon] - $day;
$_day_time = $hr * $_hour_power + $min * $_min_power + $sec;
$_day_time = $_day_power - $_day_time;
$ret = -($_total_date * $_day_power + $_day_time - $gmt_different);
if ($ret < -12220185600.0) {
$ret += 10 * 86400;
} else {
if ($ret < -12219321600.0) {
$ret = -12219321600.0;
}
}
// if in limbo, reset to 15 Oct 1582.
}
//print " dmy=$day/$mon/$year $hr:$min:$sec => " .$ret;
return $ret;
}
示例2: O
/**
Return a timestamp given a local time. Originally by jackbbs.
Note that $is_dst is not implemented and is ignored.
Not a very fast algorithm - O(n) operation. Could be optimized to O(1).
*/
function adodb_mktime($hr, $min, $sec, $mon = false, $day = false, $year = false, $is_dst = false, $is_gmt = false)
{
if (!defined('ADODB_TEST_DATES')) {
if ($mon === false) {
return $is_gmt ? @gmmktime($hr, $min, $sec) : @mktime($hr, $min, $sec);
}
// for windows, we don't check 1970 because with timezone differences,
// 1 Jan 1970 could generate negative timestamp, which is illegal
$usephpfns = 1971 < $year && $year < 2038 || !defined('ADODB_NO_NEGATIVE_TS') && (1901 < $year && $year < 2038);
if ($usephpfns && $year + $mon / 12 + $day / 365.25 + $hr / (24 * 365.25) >= 2038) {
$usephpfns = false;
}
if ($usephpfns) {
return $is_gmt ? @gmmktime($hr, $min, $sec, $mon, $day, $year) : @mktime($hr, $min, $sec, $mon, $day, $year);
}
}
$gmt_different = $is_gmt ? 0 : adodb_get_gmt_diff($year, $mon, $day);
/*
# disabled because some people place large values in $sec.
# however we need it for $mon because we use an array...
$hr = intval($hr);
$min = intval($min);
$sec = intval($sec);
*/
$mon = intval($mon);
$day = intval($day);
$year = intval($year);
$year = adodb_year_digit_check($year);
if ($mon > 12) {
$y = floor(($mon - 1) / 12);
$year += $y;
$mon -= $y * 12;
} else {
if ($mon < 1) {
$y = ceil((1 - $mon) / 12);
$year -= $y;
$mon += $y * 12;
}
}
$_day_power = 86400;
$_hour_power = 3600;
$_min_power = 60;
$_month_table_normal = array("", 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$_month_table_leaf = array("", 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$_total_date = 0;
if ($year >= 1970) {
for ($a = 1970; $a <= $year; $a++) {
$leaf = _adodb_is_leap_year($a);
if ($leaf == true) {
$loop_table = $_month_table_leaf;
$_add_date = 366;
} else {
$loop_table = $_month_table_normal;
$_add_date = 365;
}
if ($a < $year) {
$_total_date += $_add_date;
} else {
for ($b = 1; $b < $mon; $b++) {
$_total_date += $loop_table[$b];
}
}
}
$_total_date += $day - 1;
$ret = $_total_date * $_day_power + $hr * $_hour_power + $min * $_min_power + $sec + $gmt_different;
} else {
for ($a = 1969; $a >= $year; $a--) {
$leaf = _adodb_is_leap_year($a);
if ($leaf == true) {
$loop_table = $_month_table_leaf;
$_add_date = 366;
} else {
$loop_table = $_month_table_normal;
$_add_date = 365;
}
if ($a > $year) {
$_total_date += $_add_date;
} else {
for ($b = 12; $b > $mon; $b--) {
$_total_date += $loop_table[$b];
}
}
}
$_total_date += $loop_table[$mon] - $day;
$_day_time = $hr * $_hour_power + $min * $_min_power + $sec;
$_day_time = $_day_power - $_day_time;
$ret = -($_total_date * $_day_power + $_day_time - $gmt_different);
if ($ret < -12220185600) {
$ret += 10 * 86400;
} else {
if ($ret < -12219321600) {
$ret = -12219321600;
}
}
//.........这里部分代码省略.........
示例3: date
/**
* Return formatted date based on timestamp $d
* @param string Format of date output
* @param int Date to be converted
* @param boolean Ignore timezone
* @return string In the format specified by $fmt
*/
function date($fmt, $d = false, $is_gmt = false)
{
static $daylight;
if ($d === false) {
return $is_gmt ? @gmdate($fmt) : @date($fmt);
}
if (abs($d) <= 0x7fffffff) {
// check if number in 32-bit signed range
if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= 0) {
// if windows, must be +ve integer
return $is_gmt ? @gmdate($fmt, $d) : @date($fmt, $d);
}
}
$_day_power = 86400;
$arr = $this->_getdate($d, true, $is_gmt);
// if (!isset($daylight)) $daylight = function_exists('adodb_daylight_sv');
// if ($daylight) adodb_daylight_sv($arr, $is_gmt);
$year = $arr['year'];
$month = $arr['mon'];
$day = $arr['mday'];
$hour = $arr['hours'];
$min = $arr['minutes'];
$secs = $arr['seconds'];
$max = strlen($fmt);
$dates = '';
/*
at this point, we have the following integer vars to manipulate:
$year, $month, $day, $hour, $min, $secs
*/
for ($i = 0; $i < $max; $i++) {
switch ($fmt[$i]) {
case 'T':
$dates .= date('T');
break;
// YEAR
// YEAR
case 'L':
$dates .= $arr['leap'] ? '1' : '0';
break;
case 'r':
// Thu, 21 Dec 2000 16:01:07 +0200
// 4.3.11 uses '04 Jun 2004'
// 4.3.8 uses ' 4 Jun 2004'
$dates .= gmdate('D', $_day_power * (3 + $this->dow($year, $month, $day))) . ', ' . ($day < 10 ? '0' . $day : $day) . ' ' . date('M', mktime(0, 0, 0, $month, 2, 1971)) . ' ' . $year . ' ';
if ($hour < 10) {
$dates .= '0' . $hour;
} else {
$dates .= $hour;
}
if ($min < 10) {
$dates .= ':0' . $min;
} else {
$dates .= ':' . $min;
}
if ($secs < 10) {
$dates .= ':0' . $secs;
} else {
$dates .= ':' . $secs;
}
$gmt = adodb_get_gmt_diff();
$dates .= sprintf(' %s%04d', $gmt < 0 ? '+' : '-', abs($gmt) / 36);
break;
case 'Y':
$dates .= $year;
break;
case 'y':
$dates .= substr($year, strlen($year) - 2, 2);
break;
// MONTH
// MONTH
case 'm':
if ($month < 10) {
$dates .= '0' . $month;
} else {
$dates .= $month;
}
break;
case 'Q':
$dates .= $month + 3 >> 2;
break;
case 'n':
$dates .= $month;
break;
case 'M':
$dates .= date('M', mktime(0, 0, 0, $month, 2, 1971));
break;
case 'F':
$dates .= date('F', mktime(0, 0, 0, $month, 2, 1971));
break;
// DAY
// DAY
case 't':
$dates .= $arr['ndays'];
//.........这里部分代码省略.........