我希望在我的网站上显示问候语。
仅当月份和日期为31 st 12月或1 st 1月
if($today =='12-31' || $today =='01-01'){
echo 'Greetings.';
}
答案 0 :(得分:0)
只需按照以后查找的格式生成 $ today ,使用PHP的date $today = date('m-d');
生成数字{month} - {day},如您所示示例代码
<?php
$today = date('m-d');
if($today =='12-31' || $today =='01-01'){
echo 'Greetings.';
}
echo $today;
答案 1 :(得分:0)
$yearend_date = strtotime('31 Dec');
$yearEnd = date('Y-m-d', $yearend_date);
$YearStart = date('Y-m-d',strtotime('+1 day',$yearend_date));
$today = date('Y-m-d');
if($yearEnd==$today || $YearStart==$today){
echo "greetings";
}