Python, Firefox programming and Irish Whiskey.

Friday, September 16, 2011

Get the week of the year in javascript

For those looking for that particular function and already using jqueryui: You already have it in datepicker widget. Just call $.datepicker.iso8601Week(date_object).

The code is simple (taken from jqueryui, so either MIT or GPL license):


I just have to warn you against the attempt to extend the built-in Date type with a new method, as some suggest. You will find enough explanations around on why it is a bad idea.