本文整理匯總了PHP中TimeDate::to_db方法的典型用法代碼示例。如果您正苦於以下問題:PHP TimeDate::to_db方法的具體用法?PHP TimeDate::to_db怎麽用?PHP TimeDate::to_db使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TimeDate
的用法示例。
在下文中一共展示了TimeDate::to_db方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testTodbCanHandleMmddyyyyFormats
/**
* @ticket 17528
*/
public function testTodbCanHandleMmddyyyyFormats()
{
$old_date = $GLOBALS['current_user']->getPreference('datef');
$GLOBALS['current_user']->setPreference('datef', 'm-d-Y');
$db_date_pattern = '/2007-10-25 [0-9]{2}:[0-9]{2}:[0-9]{2}/';
$this->assertRegExp($db_date_pattern, $this->time_date->to_db('10-25-2007'));
$GLOBALS['current_user']->setPreference('datef', $old_date);
}
示例2: eval
function get_parameter_value($rp, $rpl)
{
global $current_language, $current_user;
if ($rp->range_name == "CURRENT_USER") {
return $current_user->id;
} else {
if ($rp->range_name == "SCRIPT") {
return eval($rp->range_options);
} else {
if ($rp->range_name == "DATE") {
$timedate = new TimeDate();
$result = $timedate->to_db_date($_REQUEST[$rpl->name], false);
return $result;
} else {
if ($rp->range_name == "DATE_NOW") {
$timedate = new TimeDate();
$result = $timedate->get_gmt_db_datetime();
return $result;
} else {
if ($rp->range_name == "DATE_ADD" || $rp->range_name == "DATE_SUB") {
$timedate = new TimeDate();
$arr = split("::", $_REQUEST[$rpl->name]);
if (count($arr) == 2) {
$count = $arr[0];
$type = $arr[1];
if ($type == "MINUTE") {
$count *= 60;
} else {
if ($type == "HOUR") {
$count *= 60 * 60;
} else {
if ($type == "DAY") {
$count *= 60 * 60 * 24;
} else {
if ($type == "WEEK") {
$count *= 60 * 60 * 24 * 7;
} else {
if ($type == "MONTH") {
$count *= 60 * 60 * 24 * 30;
} else {
if ($type == "YEAR") {
$count *= 60 * 60 * 24 * 365;
}
}
}
}
}
}
if ($rp->range_name == "DATE_SUB") {
$count *= -1;
}
} else {
$count = 0;
}
$time = time();
$time += $count;
$result = date('Y-m-d H:i:s', $time);
$result = $timedate->to_db($result);
return $result;
} else {
return $_REQUEST[$rpl->name];
}
}
}
}
}
}