 |
|
พี่ๆครับช่วยหน่อยครับจะเพิ่ม second ของโค๊ดนี้ต้องเขียนยังไงหรอครับ [นับเวลาถอยหลัง PHP (ไม่ใช่ js นะครับ PHP) ]
Code (PHP)
<?php
// First include the class file and make a new object
include("countdown.class.php");
$CountDown = new CountDown;
// The next code will set a different format for the countdown.
// You can use the following replacement strings:
// {W} This is the number of weeks
// {Ws} Either an 's' or nothing. Use as {W} week{Ws} in case it's 1 week, and not 1 weeks.
// {D} Number of days
// {Ds} Same as {Ws} but for days
// {H} Number of hours
// {Hs} Same as {Ws} but for hours
// {M} Number of minutes
// {Ms} Same as {Ws} but for minutes
$CountDown->format = "Days: {D}<br />Hours: {H} <br />Min :{M}";
$day = "26"-1;
$out = $CountDown->Give(20,0,0,3,$day,2015);
echo $out."<br />";
?>
Code (PHP)
<?php
/* CountDown PHP class
* Made by Angelo Geels 2010
* http://angelog.nl/
*/
class CountDown{
public $finished = "Countdown reached!";
public $format = "{W} week{Ws}, {D} day{Ds}, {H} hour{Hs} and {M} minute{Ms} left";
function Give($hour,$minute,$second,$month,$day,$year,$print = false){
$date = mktime($hour,$minute,$second,$month,$day,$year);
$timeleft = $date - time();
if($timeleft<0){
if($print)
echo $this->finished;
else
return $this->finished;
}else{
$w = floor((($timeleft / 3600) / 24) / 7);
$ws = ($w==1) ? "" : "s";
$d = floor(($timeleft / 3600) / 24) - $w * 7;
$ds = ($d==1) ? "" : "s";
$h = floor($timeleft / 3600) - floor(($timeleft / 3600) / 24) * 24;
$hs = ($h==1) ? "" : "s";
$m = floor($timeleft / 60) - floor($timeleft / 3600) * 60;
$ms = ($m==1) ? "" : "s";
$out = $this->format;
$find = array("{W}","{Ws}","{D}","{Ds}","{H}","{Hs}","{M}","{Ms}");
$replace = array($w,$ws,$d,$ds,$h,$hs,$m,$ms);
$out = str_replace($find,$replace,$out);
if($print)
echo $out;
else
return $out;
}
}
}
?>
Tag : PHP, MySQL, HTML/CSS, JavaScript, CakePHP
|
|
 |
 |
 |
 |
Date :
2014-03-26 10:58:30 |
By :
aibot |
View :
673 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |