Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个函数,它定义了当月从一周中的哪一天开始:
public function firstDayOfMonth() { $day = (int) date("w", strtotime(date('m').'/01/'.date('Y').' 00:00:00')); return $day; }
如果我给它输入,例如“六月”,我将如何更改上述内容,以使我能够获得该月开始的星期几。
您可以将代码简化为:
$month = 'June'; $day = (int) date('w', strtotime($month));
public function firstDayOfMonth($month) { $day = (int) date("w", strtotime($month . ' 01,' . date('Y') . ' 00:00:00')); return $day; }