如何从日期找到一个月的最后一天? [英] How to find the last day of the month from date?
本文介绍了如何从日期找到一个月的最后一天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$ p
$ b
$ a_date =2009-11-23
我想要2009- 11-30;并给出
$ a_date =2009-12-23
我想要2009-12-31。
解决方案
t
返回给定日期的月份天数(见 日期的文档
):
$ a_date =2009-11-23;
echo date(Y-m-t,strtotime($ a_date));
How can I get the last day of the month in PHP?
Given:
$a_date = "2009-11-23"
I want 2009-11-30; and given
$a_date = "2009-12-23"
I want 2009-12-31.
解决方案
t
returns the number of days in the month of a given date (see the docs for date
):
$a_date = "2009-11-23";
echo date("Y-m-t", strtotime($a_date));
这篇关于如何从日期找到一个月的最后一天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文