jQuery Countdown
Unobtrusive and easily skinable countdown jQuery plugin generating a <time>
tag.
Supported browsers
To use the countdown jQuery plugin you need an up-to-date web browser supporting the HTML5 time element.
Installation
Get the plugin from npm
:
$ npm install jquery.countdown
Or include this script after jQuery.
Usage
Create a countdown from the value of the datetime
attribute of a <time>
tag (valid global date and time, time or duration).
Friday, December 13th, 2013 5:43pmExpires in 2 hours 30 minutes 30 seconds61 days
Create a countdown from a valid global date and time string (with time-zone offset).
2012-12-08T17:47:00+0100<!-- Paris (winter) -->2012-12-08T08:47:00-0800<!-- California -->2012-12-08T16:47:00+0000<!-- UTC -->
Create a countdown from a valid time string.
12:3012:30:3912:30:39.929
Create a countdown from a valid duration string.
P2DPT01H01M15SPT20M20SPT10S
Create a countdown from the string representation of a Python timedelta
object.
600 days, 3:59:1200:59:003:59:12
Create a countdown from a human readable duration string.
24h00m59s2h 0m4h 18m 3s600 days, 3:59:12600 jours, 3:59:1200:01240:00:59
Create a countdown from a string that can be interpreted by the JavaScript Date.parse()
function.
Rock'n'roll
;
Available options
css_class
: the css class of the generated<time>
tag (default:countdown
).always_show_days
: always display days if true even if none remains (default:false
).with_labels
: display or hide labels (default:true
).with_seconds
: display or hide seconds (default:true
).with_separators
: display or hide separators between days, hours, minutes and seconds (default:true
).with_hh_leading_zero
: always display hours in 2 digit format with a leading zero when appropriate (default:true
).with_mm_leading_zero
: always display minutes in 2 digit format with a leading zero when appropriate (default:true
).with_ss_leading_zero
: always display seconds in 2 digit format with a leading zero when appropriate (default:true
).label_dd
: label's text for days (default:days
).label_hh
: label's text for hours (default:hours
).label_mm
: label's text for minutes (default:minutes
).label_ss
: label's text for seconds (default:seconds
).separator
: separator character between hours, minutes and seconds (default::
).separator_days
: separator character between days and hours (default:,
).
Events
time.elapsed
: this event fires immediately when the time is elapsed.
;
time.tick
: by default, this event fires every second(ish), the second passed parameter is the number of miliseconds left. Useful if you're doing something like a bar that fills up as time runs out.
;
Generated markup
A valid <time>
tag representing a duration is generated.
days , hours : minutes : seconds
Acknowledgements
Released under the MIT License.
Issues should be opened through GitHub Issues.
jQuery Countdown is authored and maintained by Kemar.