每个月的第一天
如果我从当前日期开始,如何获得每个月的第一个星期五?
我正在考虑使用 $date->get(Zend::WEEKDAY) 并将其与星期五进行比较,然后与 DAY 进行比较,并检查它是否小于或等于 7。然后添加 1 个月。
一定有更简单的东西吗?
If I start with the current date, how can I get the first Friday of each month?
I was thinking about using $date->get(Zend::WEEKDAY) and comparing that to Friday and then with DAY and checking if it is less than or equal to 7. Then adding 1 month onto it.
There must be something simpler?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
怎么样
或者把它变成一个方便的函数:-
你可以像这样将它与 Zend_Date 一起使用:-
然后
Zend_Debug::dump($zDate->toString());
将产生:-I'我想说这要简单得多:)
经过更多思考后进行编辑:
更通用的函数可能对您更有用,所以我建议使用这个:-
这些天我的首选方法是延长PHP 的 DateTime 对象:-
给出:-
How about
Or turn it into a handy function:-
You could use this with Zend_Date like this:-
Then
Zend_Debug::dump($zDate->toString());
will produce :-I'd say that's a lot simpler :)
Edit after some more thought:
A more generalised function may be of more use to you, so I'd suggest using this:-
These days my preferred method is to extend PHP's DateTime object:-
Gives:-