Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Countdown edit date

    Hello.
    I would like to have a countdown timer on my website.

    i picked a source, but i dont know how i can set the time.
    Is there anyone who can help me?

    You can download the code at:
    http://www.land-of-web.com/freebies/...#comment-29294

    The date to count to is 31-12-2014.

    In first part of the jquery.countdown.js file, you'll see 'until: null, '. I think the date can be filled in over there, but it won't work for me)

    This is a little bit of the code:
    Code:
    /* Display a countdown timer.
       Attach it with options like:
       $('div selector').countdown(
           {until: new Date(2009, 1 - 1, 1, 0, 0, 0), onExpiry: happyNewYear}); */
    
    (function($) { // Hide scope, no $ conflict
    
    /* Countdown manager. */
    function Countdown() {
    	this.regional = []; // Available regional settings, indexed by language code
    	this.regional[''] = { // Default regional settings
    		// The display texts for the counters
    		labels: ['Jaren', 'Maanden', 'Weken', 'Dagen', 'Uren', 'Minuten', 'Seconden'],
    		// The display texts for the counters if only one
    		labels1: ['Jaar', 'Maand', 'Week', 'Dag', 'Uur', 'Minuut', 'Seconde'],
    		compactLabels: ['y', 'm', 'w', 'd'], // The compact texts for the counters
    		whichLabels: null, // Function to determine which labels to use
    		timeSeparator: ':', // Separator for time periods
    		isRTL: false // True for right-to-left languages, false for left-to-right
    	};
    	this._defaults = {
    		until: null,  // new Date(year, mth - 1, day, hr, min, sec) - date/time to count down to
    			// or numeric for seconds offset, or string for unit offset(s):
    			// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
    		since: null, // new Date(year, mth - 1, day, hr, min, sec) - date/time to count up from
    			// or numeric for seconds offset, or string for unit offset(s):
    			// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
    		timezone: 1, // The timezone (hours or minutes from GMT) for the target times,
    			// or null for client local
    		serverSync: null, // A function to retrieve the current server time for synchronisation
    		format: 'dHMS', // Format for display - upper case for always, lower case only if non-zero,
    			// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
    		layout: '', // Build your own layout for the countdown
    		compact: false, // True to display in a compact format, false for an expanded one
    		significant: 0, // The number of periods with values to show, zero for all
    		description: '', // The description displayed for the countdown
    		expiryUrl: '', // A URL to load upon expiry, replacing the current page
    		expiryText: '', // Text to display upon expiry, replacing the countdown
    		alwaysExpire: false, // True to trigger onExpiry even if never counted down
    		onExpiry: null, // Callback when the countdown expires -
    			// receives no parameters and 'this' is the containing division
    		onTick: null, // Callback when the countdown is updated -
    			// receives int[7] being the breakdown by period (based on format)
    			// and 'this' is the containing division
    		tickInterval: 1 // Interval (seconds) between onTick callbacks
    	};


    Kind regards,

    Paul

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,680
    Thanks
    6
    Thanked 1,009 Times in 982 Posts
    You don’t change anything in this file. The comment at the top just explains how to set up a timer. But this file is only the plugin code and should not be touched.

    First, you need to include jQuery, then you need to include this plugin file, and lastly, you need to actually set up the timer, and you would do that either in an additional script block in your HTML file or in another JS file where you put all your custom functions.

    Something like this (just a demonstration, don’t just copy and paste):
    Code:
    <script src="jquery.js"></script>
    <script src="countdown_plugin.js"></script>
    <script src="custom_functions.js"><script>
    Where the custom functions file would have this code:
    Code:
    $(function() {
      $('#example').countdown({
        until: new Date(2014, 12 - 1, 31, 0, 0, 0)
      });
    });
    And in your HTML you need an element with an ID. That ID can be anything (I’ve chosen “example” here) but the selector in the function must match this ID, of course.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •