我试图获取下一个“本月第二个星期日”的时间戳,不管它是在当前月还是在下个月。PHP strtotime - 获取第二个最近的“本月第二个星期日”
需求是使用strtotime函数,只有一次,没有第二个参数,没有更多(这些约束来自遗留代码)。
基本上PHP代码来获取一定是唯一的:
strtotime('_a_string_here_');
和字符串必须是一个通用的字符串。它不能包含'feb 2011'之类的东西。
基本上我可以放一个静态字符串作为strtotime函数的第一个参数。
我已经尝试了所有的这些,但他们不给我我想要的(现在的日期是周四2011-02-24):
strtotime('second sunday')
//返回“2011-03-06 00:00: 00'
strtotime('second sunday of the month ')
// 1970-01-01 00:00:00
strtotime('+0 month second sun')
//返回 '2011-03-06 00:00:00'
感谢,
丹
尝试“第二个星期日”相对于“2001年2月1日”(第二个参数),但要小心,如果一开始的一天是星期日 – 2011-02-24 15:43:18
对不起,我加我不能使用第二个参数。反正为了得到2011-02-01,我需要调用另一个PHP函数(这是对约束) – dan 2011-02-24 15:47:18
可能更改标题是“的strtotime”而不是“用strtolower” – DTest 2011-02-24 16:08:00