如何获得当月的天数?在PHP中 [英] how to get the number of days of the current month? in PHP

查看:162
本文介绍了如何获得当月的天数?在PHP中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查一下今天是今天的最后一天,但我真的不知道如何。
i想在php中写。

i want to check if today is the last day of the month, but i don't really know how. i want to write it in php.

你可以帮忙吗?

谢谢,
Sebastian

thanks, Sebastian

推荐答案

可能有一个比这更优雅的解决方案,但你可以使用php的日期功能:

There is probably a more elegant solution than this but you can just use php's date function:

$maxDays=date('t');
$currentDayOfMonth=date('j');

if($maxDays == $currentDayOfMonth){
  //Last day of month
}else{
  //Not last day of the month
}

这篇关于如何获得当月的天数?在PHP中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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