本文整理汇总了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];
}
}
}
}
}
}