文章目录[隐藏]
示例代码
$Cache = new ESApi();
$json = $Cache->getWeekDay("2019-12-27");
echo json_encode($json,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
/**
* @param null $date
* @param bool $today
* @param bool $smple
* @return array
* @describe:获取当天或者指定日期是星期几
*/
class ESApi{
public function getWeekDay($date = null, $today = true, $smple = true){
$weekarray = ["日", "1", "2", "3", "4", "5", "6"]; //先定义一个数组
if ($smple == true) {
$weekarray = ["日", "一", "二", "三", "四", "五", "六"]; //先定义一个数组
}
$arr = [];
if ($today) {
$arr['Todayweek'] = "星期" . $weekarray[date("w")];
}
if (!empty($date)) {
$arr['Otherweek'] = "星期" . $weekarray[date("w", strtotime($date))];
}
return $arr;
}
}
返回数据
{ "Todayweek": "星期三", "Otherweek": "星期五" }
本文由 陌涛 发布在 陌涛的记事本,转载此文请保持文章完整性,并请附上文章来源(陌涛的记事本)及本页链接。
原文链接:https://imotao.com/4424.html