本文整理汇总了PHP中tool::get_week_en方法的典型用法代码示例。如果您正苦于以下问题:PHP tool::get_week_en方法的具体用法?PHP tool::get_week_en怎么用?PHP tool::get_week_en使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tool
的用法示例。
在下文中一共展示了tool::get_week_en方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_date_byweek
public static function get_date_byweek($week, $type = 1, $reftime = NULL)
{
if ($type == 1) {
$weeknum = tool::get_week_en($week);
if (!empty($reftime)) {
$max = 5;
$getdate = '';
for ($i = 0; $i <= $max; $i++) {
$timeadd = strtotime($reftime) + $i * 86400;
$timedef = strtotime($reftime) - $i * 86400;
if (date('D', $timeadd) == $weeknum) {
$getdate = $timeadd;
break;
} elseif (date('D', $timedef) == $weeknum) {
$getdate = $timedef;
break;
}
}
if (!empty($getdate)) {
return date("Y-m-d", $getdate);
} else {
return date("Y-m-d", time());
}
}
if ($weeknum == '') {
return date("Y-m-d H:i:s", time());
} else {
return date("Y-m-d H:i:s", strtotime($weeknum));
}
} elseif ($type == 2) {
$weektype = array('Mon' => '1', 'Tue' => '2', 'Wed' => '3', 'Thu' => '4', 'Fri' => '5', 'Sat' => '6', 'Sun' => '7');
$weeknum = '';
foreach ($weektypek as $key => $value) {
$check = strpos($week, $value);
if ($check !== FALSE) {
$weeknum = $key;
break;
}
}
if (!empty($reftime)) {
$max = 5;
$getdate = '';
for ($i = 0; $i <= $max; $i++) {
$timeadd = strtotime($reftime) + $i * 86400;
$timedef = strtotime($reftime) - $i * 86400;
if (date('D', $timeadd) == $weeknum) {
$getdate = $timeadd;
break;
} elseif (date('D', $timedef) == $weeknum) {
$getdate = $timeadd;
break;
}
}
if (!empty($getdate)) {
return date("Y-m-d", $getdate);
} else {
}
}
if ($weeknum == '') {
return date("Y-m-d H:i:s", time());
}
//当参考时间不能为空(参考时间前后5日内是否有相应日期)
if (!empty($reftime)) {
$max = 5;
$getdate = '';
for ($i = 0; $i <= $max; $i++) {
$timeadd = strtotime($reftime) + $i * 86400;
$timedef = strtotime($reftime) - $i * 86400;
if (date('D', $timeadd) == $weeknum) {
$getdate = $timeadd;
break;
} elseif (date('D', $timedef) == $weeknum) {
$getdate = $timeadd;
break;
}
}
} else {
return date("Y-m-d H:i:s", strtotime($weeknum));
}
if ($weeknum == '') {
return date("Y-m-d H:i:s", time());
} else {
return date("Y-m-d H:i:s", strtotime($weeknum));
}
}
}