1 posts by 1 authors in: Forums > CMS Builder Community
Last Post: September 22, 2014   (RSS)

Here's a Countdown to Event if the date is greater than now, which uses jQuery and provides an active countdown without the need for the page to refresh. Hope anyone who needs this finds it useful. See the URL to download the files you'll need for the jQuery function.

<?php header('Content-type: text/html; charset=utf-8'); ?>
  // load viewer library
  $libraryPath = 'cmsBuilder/lib/viewer_functions.php';
  $dirsToCheck = array('/home/server/html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
  // load records
  list($eventsRecords, $eventsMetaData) = getRecords(array(
    'tableName'   => 'events',
    'where'       => whereRecordNumberInUrl(1),
    'limit'       => '1',
  $eventsRecord = @$eventsRecords[0]; // get first record

<!doctype html>
<meta charset="UTF-8">
<title>Countdown to Event</title>

<style type="text/css">
#countdown {
font-family:"Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;

<script src="jquery.1.11.0.js" type="text/javascript"></script>
<script src="jquery.countdown.js" type="text/javascript">
// download jquery.countdown.js here: http://hilios.github.io/jQuery.countdown/


<div id="countdown"></div>
<div class="clear-both"></div>
<script type="text/javascript">
//.countdown("2015/01/01", function(event) {
.countdown("<?php echo $eventsRecord['date'] ?>", function(event) {
event.strftime('%D days %H:%M:%S')

Cheers, Zicky