I want to convert a date string to a date object in jQuery, and the code below is great for Chrome and Firefox, but not Internet Explorer:
<script type="text/javascript" charset="utf-8">
jQuery.noConflict();
var now = new Date();
jQuery(".FollowUpDate").each(function () {
if (jQuery(this).text().trim() != "") {
var followupDate = new Date(jQuery(this).text().trim());
alert(followupDate);
if (followupDate <= now) {
jQuery(this).removeClass('current');
jQuery(this).addClass('late');
}
else {
jQuery(this).removeClass('late');
jQuery(this).addClass('current');
}
}
});
</script>
The warning is only available for testing, and in Chrome and Firefox it returns a date object, but in IE I get NaN.
What is wrong, and how can I do this conversion to make it work in IE too?
source
share