Just a widget wrapper for Keith Wood's JQuery Countdown extension. Localization doesn't work yet.
Requirements ¶
- Yii 1.1 or above (might work for Yii 1.0 but haven't really tested there)
- JQuery core script enabled
Usage ¶
$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>' )));
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));
to:
public function init() { $path = Yii::app()->getAssetManager()->publish( dirname(__FILE__).DIRECTORY_SEPARATOR .'src',-1,YII_DEBUG );
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));
Want Multiple Countdown Timers?
Where you implement the countdown timer, be sure to set a unique _elementid:
<?php $this->widget('ext.kwcountdown.KWCountdown', array( 'element_id'=>'countdown_'.$counter, 'until_seconds'=>$until_seconds, )); ?>
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);
mysql datetime to UNIX timestamp?
How can I convert mysql datetime to UNIX timestamp ?
My problem is: <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 !!!
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.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.