user3358269
user3358269

Reputation: 11

jQuery Countdown - Change 0 Days Into Today

I'm working on countdown page using Keith Woods Countdown jquery plugin http://keith-wood.name/countdown.html. And this is what I have so far

$(document).ready(function () {
var segera = new Date();
segera = new Date(segera.getFullYear(), 2 - 1, 28);
$('.days').countdown({
    until: segera,
    layout: '{dn} {dl}',
    timezone: +7
});
$('.hours').countdown({
    until: segera,
    layout: '{hn} {hl} {mn} {ml}',
    timezone: +7
});
});

The question is, how can I change the day format? So, instead of displaying 0 DAYS, it will display TODAY. Any help would really be appreciated...

//// EDIT

A facebook friend helped me. And here's what worked for me.

$(document).ready(function () {
var segera = new Date();
segera = new Date(segera.getFullYear(), 2 - 1, 28);
$('.days').countdown({
    until: segera,
    layout: '{dn} {dl}',
    timezone: +7,
    expiryText: "TODAY"
});
$('.hours').countdown({
    until: segera,
    layout: '{hn} {hl} {mn} {ml}',
    timezone: +7
});
var hari = $('.days').text();
if (hari == "0 Days") {
    $('.days').css('display', 'none');
    $('.result').text('Today');
}
});

See jsfiddle

Upvotes: 1

Views: 150

Answers (2)

Steven P
Steven P

Reputation: 1

You may need to set "alwaysExpire: true" in the parameters

Upvotes: 0

Quinn
Quinn

Reputation: 458

You can set the expiryText property to any string you want:

$(document).ready(function () {
    var segera = new Date();
    segera = new Date(segera.getFullYear(), 2 - 1, 28);
    $('.days').countdown({
        until: segera,
        layout: '{dn} {dl}',
        timezone: +7,
        expiryText: "TODAY"
    });
    $('.hours').countdown({
        until: segera,
        layout: '{hn} {hl} {mn} {ml}',
        timezone: +7,
        expiryText: "TODAY"
    });
});

Source (look for "expiryText")

Upvotes: 1

Related Questions