php在特定日期后的第一个星期一作为字符串 [英] php first monday after certain date as string
本文介绍了php在特定日期后的第一个星期一作为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个以字符串形式给出的日期.我想在这个给定日期之后的第一个星期一,再次作为字符串.
I have a date given as a string. And I would like to get the first monday after this given date, again as a string.
$myDate = "2014-08-24"; // date given in Y-m-d
$nextMonday = ??? // how to get the next monday after $myDate?
这听起来像是之前已解决的问题,例如何时给定日期,如何在php中获取该周的星期一的日期. 但这实际上是一个不同的问题,因为我遇到了很多转换问题,并且对如何解决这个问题有些困惑.
This sounds like a question that was solved before, like PHP get next occurrence of Monday from a certain date (with time) or When a date is given how to get the date of Monday of that week in php. But it actually is a different problem, because I am running into a lot of conversion issues and a little bit confused how to solve this.
推荐答案
您可以使用此
<?php
$myDate = "2014-08-27";
$next_monday = date('Y-m-d', strtotime("next monday", strtotime($myDate)));
echo $next_monday;
?>
输出:
2014-09-01
Demo
这篇关于php在特定日期后的第一个星期一作为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文