大家好,我想获取当前日期的月份。PHP获取日期的当前月份
这是我的尝试:
<?php
$transdate = date('m-d-Y', time());
echo $transdate;
$month = date('m', strtotime($transdate));
if($month == "12"){
echo "<br />December is the month :)";
} else {
echo "<br /> The month is probably not December";
}
?>
但结果是错误的,它应该显示十二月是本月:0
任何想法?谢谢。
它对我来说工作正常 –
为什么你不运行第二个日期功能与时间()作为第二个参数,你运行两次? :? –
'if($ month == 12)'。 12应该是整数不是字符串 –