Can I get the third Wednesday in php with strtotime ("wed year-month +2 Weeks") or do I need a complex code like here: http://www.danielkassner.com/2010/05/22/get-date-by-position-ie-third-wednesday-of-january?
2条回答 默认 最新
- dongqiang4819 2012-09-19 13:53关注
Try this:-
/** * int nth_day_of_month(int $nbr, str $day, int $mon, int $year) * $nbr = nth weekday to find * $day = full name of weekday, e.g. "Saturday" * $mon = month 1 - 12 * $year = year 1970, 2007, etc. * returns UNIX time */ function nth_day_of_month($nbr, $day, $mon, $year) { $date = mktime(0, 0, 0, $mon, 0, $year); if($date == 0) { user_error(__FUNCTION__."(): Invalid month or year", E_USER_WARNING); return(FALSE); } $day = ucfirst(strtolower($day)); if(!in_array($day, array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'))) { user_error(__FUNCTION__."(): Invalid day", E_USER_WARNING); return(FALSE); } for($week = 1; $week <= $nbr; $week++) { $date = strtotime("next $day", $date); } return($date); } $d = nth_day_of_month($week_no,$curr_week_day, $fmonth, $fyear); echo date('d-m-Y',$d)."<br />";
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
- ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
- ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
- ¥15 如何在炒股软件中,爬到我想看的日k线
- ¥15 seatunnel 怎么配置Elasticsearch
- ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
- ¥15 (标签-MATLAB|关键词-多址)
- ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
- ¥500 52810做蓝牙接受端
- ¥15 基于PLC的三轴机械手程序