检索给定年份的所有&ŧ039;星期一&ŧ039;的。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了检索给定年份的所有&ŧ039;星期一&ŧ039;的。相关的知识,希望对你有一定的参考价值。

This is a simple function that will return an array of all the dates corresponding to the day 'Monday' for a given year. It's pretty simple and may not be the cleanest way but it works for my purpose.
  1. function getMondays($year) {
  2. $newyear = $year;
  3. $week = 0;
  4. $day = 0;
  5. $mo = 1;
  6. $mondays = array();
  7. $i = 1;
  8. while ($week != 1) {
  9. $day++;
  10. $week = date("w", mktime(0, 0, 0, $mo,$day, $year));
  11. }
  12. array_push($mondays,date("r", mktime(0, 0, 0, $mo,$day, $year)));
  13. while ($newyear == $year) {
  14. $x = strtotime(date("r", mktime(0, 0, 0, $mo,$day, $year)) . "+" . $i . " week");
  15. $i++;
  16. if ($year == date("Y",$x)) {
  17. array_push($mondays,date("r", $x));
  18. }
  19. $newyear = date("Y",$x);
  20. }
  21. return $mondays;
  22. }

以上是关于检索给定年份的所有&ŧ039;星期一&ŧ039;的。的主要内容,如果未能解决你的问题,请参考以下文章

检查是否安装了Apache&ŧ039;的modŧu rewrite。

使用TextMate&ŧ039;的tmŧdialog命令创建用户定义的菜单

用户PHP&ŧ039;的herdoc语法

设置select&ŧ039;的选定值

枚举SSID&ŧ039;s

使用TextMate&ŧ039;s tmŧdialog命令显示警报框