PHP:如何获取过去的特定日期的上一个星期日? [英] PHP: How to get previous Sunday of a specific date in the past..?

查看:398
本文介绍了PHP:如何获取过去的特定日期的上一个星期日?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从数据库中检索一个与之相关的日期的条目。



我想能够获得上一个星期日和下一个星期六相对于该特定日期填充jQuery日期戳。



我知道如何使用实际的时间/日期:

  strtotime('last Sunday') 

但是我不知道如何为现在以外的日期做...



谢谢。

解决方案

使用第二个参数 strtotime 指定计算上周日的日期和其他相关日期:

  strtotime ('上周日',strtotime('09 / 01/2010')); 

http://us2.php.net/strtotime



示例:



<$ p $回显日期('m / d / Y',strtotime('last Sunday',strtotime('09 / 01/2010')));

输出:

 code> 08/29/2010 


I'm retrieving an entry from a database with a date associated with it.

I want to be able to get the previous Sunday and the next Saturday relative to that specific date to populate a jQuery datepicker.

I know how to do it with the actual time/date with :

strtotime('last Sunday')

but I don't know how to do that for a date other than now...

Thanks.

解决方案

Use the second argument of strtotime to specify the date to calculate "last Sunday" and other relative dates from:

strtotime('last Sunday', strtotime('09/01/2010'));

http://us2.php.net/strtotime

Example:

echo date('m/d/Y', strtotime('last Sunday', strtotime('09/01/2010')));

Output:

08/29/2010

这篇关于PHP:如何获取过去的特定日期的上一个星期日?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆