简体   繁体   English

使用strtotime在日期之前查找日期

[英]Using strtotime to find date before a date

I have a very simple question I would like to pose, but the answer is eluding me. 我想提出一个非常简单的问题,但答案是躲避我。 I have a date (such as "first sunday in April") and I am trying to find the day before this, using the php strtotime function. 我有一个约会(例如“四月的第一个星期天”),我正在尝试使用php strtotime函数找到前一天。 It occurred to me that this would be harder using any other bespoke method as I'd have to take into account the number of days in a month in case (for instance), the first sunday in April was the 1st. 在我看来,使用任何其他定制方法会更难,因为我必须考虑一个月中的天数(例如),4月的第一个星期日是第一天。 Ive tried the obvious solutions like "first sunday in April - 1 day" and "1 day before first Sunday in April". 我尝试了一些明显的解决方案,比如“四月的第一个星期日 - 一天”和“四月的第一个星期天的前一天”。

I'm hoping it can be done in one step rather than find the output of strtotime and then perform arithmetic on its results. 我希望它可以一步完成,而不是找到strtotime的输出,然后对其结果进行算术运算。

I'm sure it must be simple. 我相信它一定很简单。 Many thanks! 非常感谢!

请尝试以下不同的相对日期/时间格式: http//php.net/manual/en/datetime.formats.relative.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM