获取给定输入的月份开始的星期几 [英] Get which day of the week the month starts on for given input
本文介绍了获取给定输入的月份开始的星期几的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个函数,定义当月开始的星期几:
I have a function which defines what day of the week the month starts on for the current month:
public function firstDayOfMonth()
{
$day = (int) date("w", strtotime(date('m').'/01/'.date('Y').' 00:00:00'));
return $day;
}
我如何改变上述方式,让我得到
How would I alter the above, in a way that allows me to get the day of the week the month starts on if I give it input, for example 'June'.
推荐答案
public function firstDayOfMonth($month) {
$day = (int) date("w", strtotime($month . ' 01,' . date('Y') . ' 00:00:00'));
return $day;
}
这篇关于获取给定输入的月份开始的星期几的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文