蓝优小窝
蓝优
始于网络,终于现实
90后 狮子座 联系

示例代码

<?php
$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": "星期五" }
声明:若无特殊注明,本文为《蓝优》原创,转载请保留文章出处。
  1. 思源
    如何获取是第几周的星期几呢 这个我一直想研究下
    • 蓝优
      @思源:有写出来了