Yii 1.1: kwcountdown

A widget wrapper for Keith Wood's Jquery Countdown

Just a widget wrapper for Keith Wood's JQuery Countdown extension. Localization doesn't work yet.


  • Yii 1.1 or above (might work for Yii 1.0 but haven't really tested there)
  • JQuery core script enabled


$seconds_of_date is equal to the Unix timestamp.

Example 1: For count down to a date, put this in the view:

$this->widget('ext.kwcountdown.KWCountdown', array('until_seconds' => $seconds_of_date));

Example 2: For count down from a date, put this in the view:

$this->widget('ext.kwcountdown.KWCountdown', array('since_seconds' => $seconds_of_date));

Example 3: With other display options such as different layout. See the link to Keith Wood's site for details about other options.

$this->widget('ext.kwcountdown.KWCountdown', array('until_seconds' => $seconds_of_date, 'options' => array('layout' => 'Till the new year: <b>{dn} {dl} {hnn}{sep}{mnn}{sep}{snn}</b>' )));


Keith Wood's JQuery Countdown

Total 5 comments

#15093 report it
Blue Spy at 2013/10/07 05:44am
Would be nice to collaborate

This is a quite a nice wrapper, but it would be nice if we could collaborate in something like github so this extension could have more features in the future.

#8187 report it
banamlehsb at 2012/05/15 12:01pm
mysql datetime to UNIX timestamp?

How can I convert mysql datetime to UNIX timestamp ? My problem is: <br/> 1. now: 2012-05-15 03:05:00 <br/> 2. endDate: 2012-05-15 08:05:00 <br/> but kwcountdown doesn't count down. if i use strtotime(). it only convert date (not time) to timestamp.

$this->widget('ext.kwcountdown.KWCountdown', array(
                'until_seconds' => strtotime($data->endDate),
                'element_id' => 'countdown' . $data->id,

i change my code to:

$this->widget('ext.kwcountdown.KWCountdown', array(
                'until_seconds' => $mAuction->convertDatetimeToTimestamp($data->endDate),
                'element_id' => 'countdown' . $data->id,

but it also doesn't work.

function convertDatetimeToTimestamp:

function convertDatetimeToTimestamp($str) {
        list($date, $time) = explode(' ', $str);
        list($year, $month, $day) = explode('-', $date);
        list($hour, $minute, $second) = explode(':', $time);
        $timestamp = mktime($hour, $minute, $second, 0, 0, 0);
        return $timestamp;

help me, please !!!

#7651 report it
edwaa at 2012/04/05 12:25am
Want Multiple Countdown Timers?

Where you implement the countdown timer, be sure to set a unique element_id:

<?php $this->widget('ext.kwcountdown.KWCountdown', array(
)); ?>

Next, on line #87 of KWCountdown.php, change this:

$cs->registerScript('count-down-script', $script);

to this:

$cs->registerScript('count-down-script_'.$this->element_id, $script);
#7589 report it
vulomon at 2012/04/01 03:49pm
Problem with implementation

What will be the format and value of $seconds_of_date.

$this->widget('ext.kwcountdown.KWCountdown', array('until_seconds' => $seconds_of_date));
#7585 report it
yiqing95 at 2012/03/31 10:37pm
great work ; minor modifying needed .

because some one don't always put extension under the extensions dir . so do a little modifying :

public function init() {    
            $path = Yii::app()->getAssetManager()->publish(
                    Yii::getPathOfAlias('ext.kwcountdown.src', -1, false));


public function init() {    
            $path = Yii::app()->getAssetManager()->publish(
                    dirname(__FILE__).DIRECTORY_SEPARATOR .'src',-1,YII_DEBUG

Leave a comment

Please to leave your comment.

Create extension