获取PHP之前的最后一个星期四

编程入门 行业动态 更新时间:2024-10-14 18:21:53
本文介绍了获取PHP之前的最后一个星期四的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我知道有关于如何在PHP中获得最后一个星期四的相似文章,但是我不想让最后一个星期四与当前日期相比较,但上周四比较给定日期。

I know there is similar post about how to get the last Thursday in PHP but I don't want to have the last Thursday compare to the current date but the last Thursday compare to a given date.

例如我有一个日期dd / mm / yyyy,我想在这个日期之前的星期四。 输入是一个字符串(字符串yymmdd的格式),我想解析以获取此日期之前的星期四。

For example I have a date dd/mm/yyyy and I want the Thursday before this date. The input is a String ( the format of the string yymmdd) that I want to parse to get the Thursday before this date.

感谢您的帮助

推荐答案

//Assumes it's strtotime parsable, you may need to insert // slashes with your given format eg (and use 4 digit years) $given=strtotime($dtstring); //It's just that easy ;) $thuBefore=strtotime("last thursday",$given);

请注意,这将永远获得上一个星期四,这意味着如果给定的日期是星期四,它会在7天前报告(但如果日期是星期五,那只会在前一天提前报告)。

Note that this will always get last thursday, meaning if the given date is a Thursday, it'll report 7 days earlier (but if the date's a Friday it'll only report one day earlier).

更多推荐

获取PHP之前的最后一个星期四

本文发布于:2023-11-27 10:44:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637747.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:一个星期   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!