PHP节日倒计时代码,时间戳戳戳

今天在写模板的时候突发奇想,香弄一个节日倒计时,哎呀,太香了,老爸在做饭,居然打错字了,2333。 我心想尼玛中国这么多节日,,,日 要写到哪会呀,然后我就偷懒了,去找度娘。 找到了网...

今天在写模板的时候突发奇想,香弄一个节日倒计时,哎呀,太香了,老爸在做饭,居然打错字了,2333。

我心想尼玛中国这么多节日,,,日 要写到哪会呀,然后我就偷懒了,去找度娘。

找到了网钛写的PHP节日戳,全名网钛公历、农历互转类PHP版(附节日倒计时) v1.0,然后就下载下来了,感觉还不错,来分享给大家,此处可以有掌声!!

isiyuan.net.zip

下载下来3个文件 index.php 查询(对我没卵用,略过),OT_NongLiGongLi.php谁TM知道这是什么(反正没有它用不了),jieri.php(节日倒计时代码。)

上面的是php 都能用,下面的版本集成到em去只需要将jieri.php复制到你想要出现的地方插入,

就是

<?php
/*
##########################################################
 名称:节日倒计时 V1.0
 作者:网钛工作室
 日期:2010-09-23
 网址:http://www.oneti.cn/
 邮箱:877873666@qq.com
 版权:可自由传播,也可修改后应用到自己程序里,但请保留该版权及注释信息
##########################################################
*/

header("Content-Type: text/html; charset=UTF-8");

// 防止 PHP 5.1.x 使用时间函数报错
if(function_exists('date_default_timezone_set')) {
        @date_default_timezone_set('PRC');        //PRC是中华人民共和国时区
}
require_once View::getView('OT_NongLiGongLi');



function OT_WeekNum($num){
        if ($num==0){ $num=7; }
        return $num;
}

$nongGong = new OT_NongLiGongLi();

$jieriArr = array();
$nowYear = date("Y");
$nowDate = date("Y-m-d");

// 公历节日
$jieriArr[]        = array($nowYear ."-1-1",        "米旦");
$jieriArr[]        = array($nowYear ."-2-14",        "情人节");
$jieriArr[]        = array($nowYear ."-3-8",        "妇女节");
$jieriArr[]        = array($nowYear ."-3-12",        "植树节");
$jieriArr[]        = array($nowYear ."-4-1",        "愚人节");
$jieriArr[]        = array($nowYear ."-4-5",        "清明节");
$jieriArr[]        = array($nowYear ."-5-1",        "劳动节");
$jieriArr[]        = array($nowYear ."-5-". (15 - date("w",strtotime($nowYear ."-5-1"))),        "母亲节");
$jieriArr[]        = array($nowYear ."-6-1",        "儿童节");
$jieriArr[]        = array($nowYear ."-6-". (22 - date("w",strtotime($nowYear ."-6-1"))),        "父亲节");
$jieriArr[]        = array($nowYear ."-9-10",        "教师节");
$jieriArr[]        = array($nowYear ."-10-1",        "国庆节");
$jieriArr[]        = array($nowYear ."-11-11",        "光棍节");
$jieriArr[]        = array($nowYear ."-11-". (26 - date("w",strtotime($nowYear ."-11-1"))),"感恩节");
$jieriArr[]        = array($nowYear ."-12-24",        "平安夜");
$jieriArr[]        = array($nowYear ."-12-25",        "圣诞节");

// 农历节日
$jieriArr[]        = array($nongGong->NongToGong(($nowYear-1) ."-12-24"),        "小年(南方)");
$jieriArr[]        = array($nongGong->NongToGong(($nowYear-1) ."-12-8"),        "腊八节");
$jieriArr[]        = array($nongGong->NongToGong(($nowYear-1) ."-12-23"),        "小年(北方)");
//$jieriArr[] = array($nongGong->NongToGong(($nowYear-1) ."-12-24"),"小年(南方)");
$jieriArr[]        = array($nongGong->NongToGong(($nowYear-1) ."-12-30"),        "除夕");
$jieriArr[]        = array($nongGong->NongToGong($nowYear ."-1-1"),                "春节");
$jieriArr[]        = array($nongGong->NongToGong($nowYear ."-1-15"),                "米宵节");
$jieriArr[]        = array($nongGong->NongToGong($nowYear ."-5-5"),                "端午节");
$jieriArr[]        = array($nongGong->NongToGong($nowYear ."-7-7"),                "七夕情人节");
$jieriArr[]        = array($nongGong->NongToGong($nowYear ."-8-15"),                "中秋节");
$jieriArr[]        = array($nongGong->NongToGong($nowYear ."-9-9"),                "重阳节");

/*
$jieriArr[]        = array($nowYear ."-9-18",        "中国国耻日");
$jieriArr[]        = array($nowYear ."-7-1",        "中共建党节");
$jieriArr[]        = array($nowYear ."-7-7",        "抗日战争纪念日");
$jieriArr[]        = array($nowYear ."-8-1",        "建军节");
$jieriArr[]        = array($nowYear ."-9-3",        "抗日战争胜利纪念日");
$jieriArr[]        = array($nowYear ."-11-7",        "十月革命纪念日");
$jieriArr[]        = array($nowYear ."-12-13",        "南京大屠杀纪念日");
$jieriArr[]        = array($nowYear ."-12-20",        "澳门回归纪念日");
*/


// 判断是否是闰年
if ($nowYear % 400 == 0 || ($nowYear % 4 == 0 && $nowYear % 100 != 0) ){
        $JRdiff=366;
}else{
        $JRdiff=365;
}

foreach ($jieriArr as $value){
        if ($JRdiff==0){ break; }
        $nowDiff = $nongGong->DateDiffDay2($nowDate,$value[0]);
        if ($nowDiff>=0){
                if ($nowDiff<$JRdiff){
                        $JRdiff = $nowDiff;
                        if ($JRdiff==0){
                                $JRstr2="";
                        }else{
                                $JRstr2="离". $JRdiff ."天";
                        }
                        $JRstr=$JRstr2 ."到『". $value[1] ."』";
                }
        }
}

if ($JRdiff<0){
        $JRstr="离". $nongGong->DateDiffDay2($nowDate,($nowYear+1) ."-1-1") ."天"."『米旦』";
}



echo($JRstr);

?>

 

然后模板里面加入OT_NongLiGongLi.php即可。附件em.zip

预览在下方!

 

 

 

  • 发表于 2021-04-19 07:05
  • 阅读 ( 269 )
  • 分类:互联网

0 条评论

请先 登录 后评论
18306910530
18306910530

664 篇文章

你可能感兴趣的文章

相关问题