🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
函数 ~~~ function getTimeWeek($time, $i = 0) { $weekarray = array("一", "二", "三", "四", "五", "六", "日"); $oneD = 24 * 60 * 60; return "周" . $weekarray[date("w", $time + $oneD * $i)]; } ~~~ 使用 ~~~ $time=time(); echo getTimeWeek($tiem); ~~~ 前端显示 ~~~ 今天: {$time|getTimeWeek}//星期 {$time|date="m月d日",###}//几月几日 明天: {php}echo (getTimeWeek($time,1));{/php} {$time+ 24 * 3600 - 1|date="m月d日",###} 后天: {php}echo (getTimeWeek($time,2));{/php} {$time+(24 * 3600 - 1)*2|date="m月d日",###} ~~~ ~~~ if(!function_exists('getTimeWeek')){//此行作用套个‘马甲’,当没有函数时执行,有效减少错误 function getTimeWeek($time, $i = 0) { $weekarray = array("日", "一", "二", "三", "四", "五", "六"); $oneD = 24 * 60 * 60; return "周" . $weekarray[date("w", $time + $oneD * $i)]; } } ~~~