如何获取一周中某一天的时间戳?
基本上,我有将当前/未来工作日转换为时间戳的要求。
例子:
today = Thu, 24 Feb 2010
weekday = Tue
next date = Tue, 1 Mar 2010
cur stamp = 1267016400
new stamp = 1267448400
Basically, I have this requirement to convert a present/future weekday to a timestamp.
Example:
today = Thu, 24 Feb 2010
weekday = Tue
next date = Tue, 1 Mar 2010
cur stamp = 1267016400
new stamp = 1267448400
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
strtotime('Tue')
将返回下周二的时间戳。strtotime('Tue', $time)
将返回给定时间戳的下一个星期二的时间戳。strtotime('Tue')
will return the timestamp of the next Tuesday.strtotime('Tue', $time)
will return the timestamp of the next Tuesday from the given timestamp.这是我最终得到的代码:
谈论过度设计!
无论如何,如果有人想在过去(上个工作日)使用它,它可以很容易地适应。
This is the code I ended up with:
Talk about over-engineering it out!
Anyway, if someone wants to use this in the past (last weekday), it can be easily adapted.
你试过吗
have you tried