倒计时代码

2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家

团购网出现,好多人需要倒计时代码 我帖一个出来
index.php

/**

* 将GMT时间戳格式化为用户自定义时区日期

*

* @param string $format

* @param integer $time 该参数必须是一个GMT的时间戳

*

* @return string

*/



function local_date($format, $time = NULL)

{

$timezone = isset($_SESSION['timezone']) ? $_SESSION['timezone'] : $GLOBALS['_CFG']['timezone'];



if ($time === NULL)

{

$time = gmtime();

}

elseif ($time <= 0)

{

return '';

}



$time += ($timezone * 3600);



return date($format, $time);

}
复制代码function chagetime($time)

{



$time = local_date($GLOBALS['_CFG']['time_format'], $time);

//echo $time;exit;

$time = explode(" ",$time);//分割时间

$date = $time[0];

$time=$time[1];

$date=explode("-",$date);



$year = (int)$date[0];

$month = (int)$date[1];

$day = (int)$date[2];

/*$time=explode(":",$time);

$hour =$time[0];

$min =$time[1];

$sec =(int)$time[2];

$hour = (int)(24-$hour);

$min =(int)(60-$min);

$time=$hour.":".$min.":".$sec;*/

switch ($month)

{

case 1:

$month_name = "Jan";

break;

case 2:

$month_name = "Feb";

break;

case 3:

$month_name = "Mar";

break;

case 4:

$month_name = "Apr";

break;

case 5:

$month_name = "May";

break;

case 6:

$month_name = "Jun";

break;

case 7:

$month_name = "Jul";

break;

case 8:

$month_name = "Aug";

break;

case 9:

$month_name = "Sep";

break;

case 10:

$month_name = "Oct";

break;

case 1:

$month_name = "Nov";

break;

case 2:

$month_name = "Dec";

break;

}

return $month_name." ".$day." ".$year." ".$time;

}
复制代码function countDown(){

var i;

var objArray =document.getElementsByTagName("label");

//alert(objArray.length);

for (i=0;i<(objArray.length);i++)

{



if (objArray[i].id.indexOf("article_")>-1)

{

objHid = document.getElementById("hid_article_" + objArray[i].id.substring(objArray[i].id.indexOf("_")+1));

//objHid.value就是对应的时间值,然后改下面就行了

var d=Date.parse(objHid.value);

var today=new Date();

var time=d-today;



var 时间=objArray[i];

if(Math.floor(time)<=0){

时间.innerHTML='抢购时间已过,谢谢您的关注!';

}

else

{

var 天=Math.floor(time/(1000*60*60*24));

var 小时=Math.floor(time/(1000*60*60))%24;

var 分=Math.floor(time/(1000*60))%60;

var 秒=Math.floor(time/1000)%60;

时间.innerHTML=天+' 天'+小时+'小时'+分+'分'+秒+'秒';

时间.style.fontSize='14px';

}

}

}

setTimeout('countDown()',1000);

}

countDown();

</script>





<label id='article_1'></label><input type='hidden' id='hid_article_1' value='<?php echo chagetime(time());?>' />
复制代码

回答:
顶你个肺啊

布局颇乱!!

includes/lib_goods.php中,找到
$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
在这段代码的后面添加??是不是啊?

支持下..

支持支持支持