Reputation: 13757
In this plugin:
http://dansnetwork.com/2010/03/27/content-expirator-jquery-content-expiration-plugin/
He is comparing the expire date d
to the current date today
, but I don't understand how today
knows what today's date is just from new Date()
:
(function($){
$.contentExpirator = function(prfx){
var pfix = prfx || 'exp';
$("[class|="+pfix+"]").each(function(){
var eString = $(this).attr('class').split(' ')[0];
var dString = eString.split('-');
var d = new Date(dString[1],dString[2].toString()-1,dString[3]);
var today = new Date();
if(d < today){
$(this).css('display','none');
}
});
}
})(jQuery);
The code works fine, I'm just asking out of curiosity for the future.
Upvotes: 2
Views: 226
Reputation: 238115
The default value for new Date()
is the current date. From the MDC docs:
If you supply no arguments, the constructor creates a Date object for today's date and time according to local time.
Upvotes: 6