Created
April 24, 2014 12:06
-
-
Save jhammann/11252263 to your computer and use it in GitHub Desktop.
If you use the great jquery countdown plugin with a datetime object from you database you may encounter some invalid date object errors in Firefox and/or IE. This code takes care of that issue by using a regex. Make sure your countdown_date string datetime is like the one used in this code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // jquery countdown: http://keith-wood.name/countdown.html | |
| var countdown_date = "07-05-1990 02:00"; | |
| var dateRegex = countdown_date.match(/(\d{2})-(\d{2})-(\d{4}) (.*)/); | |
| var newDate = dateRegex[3] + "/" + dateRegex[2] + "/" + dateRegex[1] + " " + dateRegex[4]; | |
| var date = new Date(newDate); | |
| $(".countdown-timer").countdown({until: date, format: "YODH", padZeroes: true}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment