[英]Get first week date of the month providing day?
Is there any PHP function that returns the date of the first week , 是否有任何PHP函数返回第一周的日期,
i:e, if i pass "Monday" , it should return 02 of september, 我:e,如果我通过“星期一”,它应该返回9月02日,
i know, how to get the day, month, date like 我知道,如何得到日,月,日期
date('l') , date('m'), date ('d')
But stuck at this point 但坚持到这一点
This should get you started: 这应该让你开始:
$dt = new DateTime('first Monday of this month');
echo $dt->format('l m d');
You can use strotime()
, like so: 您可以使用strotime()
,如下所示:
function getDateFromDay($day) {
return date('d-m-Y', strtotime("first $day of this month"));
}
Usage: 用法:
echo getDateFromDay('Monday');
Output: 输出:
02-09-2013
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.