[英]How to determine the day of the week by the date?
I want to display a week by date: 我想按日期显示一个星期:
Mon Tue Wed Thu Fri
2011-12-12 2011-12-13 2011-12-14 2011-12-15 2011-12-16
For example, I have the date 2011-12-14. 例如,我的日期为2011-12-14。 How do I determine which day of the week it is? 如何确定星期几?
You can use strtotime() 's this week
selector. 您可以使用strtotime()的this week
选择器。
<?php
$ts_today = strtotime('2011-12-14');
$ts_firstDayOfWeek = strtotime('this week', $ts_today);
echo 'today: ', date('Y-m-d', $ts_today), "\n";
echo 'week start: ', date('Y-m-d', $ts_firstDayOfWeek), "\n";
prints 版画
today: 2011-12-14
week start: 2011-12-12
date("l",strtotime("2011-12-14"));
在这里查看更多信息
I think you are looking for 我想你在找
getdate(time_stamp);
you can access the day of the week by using the following. 您可以使用以下内容访问星期几。
$day = getdate(time_stamp);
echo $day['wday'];
note: this will return the day of the week as a number Sunday = 0 - Saturday = 6 注意:这将返回星期几,数字为Sunday = 0-Saturday = 6
more info > http://php.net/manual/en/function.getdate.php 更多信息> http://php.net/manual/zh/function.getdate.php
$date = '2011/12/14';
$weekday = date('l', strtotime($date));
echo $weekday;
print the real day name. 打印真实的日期名称。
string date ("l", strtotime("2011-12-12"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.