Skip to content

Instantly share code, notes, and snippets.

Created December 20, 2012 12:54
Show Gist options
  • Save anonymous/4345149 to your computer and use it in GitHub Desktop.
Save anonymous/4345149 to your computer and use it in GitHub Desktop.
the colour of today.
$.fn.colorToday = function(property){
var now = new Date(),
color = '#',
day = now.getDate(),
month = now.getMonth() + 1,
year = now.getFullYear().toString().slice(2);
day < 10 && (day = '0' + day);
month < 10 && (month = '0' + month);
color += day.toString() + month.toString() + year;
this.css(property || 'background-color', color);
}
$('body').colorToday();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment