Created
February 9, 2014 18:22
-
-
Save mallendeo/8903557 to your computer and use it in GitHub Desktop.
Get start and end of week with Momentjs
This file contains 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
// include jquery, momentjs | |
$(function () { | |
var m = moment(); | |
m.lang('es'); // week start on monday | |
var start = m.startOf('week').format('DD'), | |
end = m.endOf('week').format('DD'), | |
month = m.endOf('week').format('MMMM'), | |
afterMonth = start > end ? ' de '+m.startOf('week').format('MMMM') : '', | |
year = m.startOf('week').format('YYYY'); | |
$('#weekDate').text('Semana del '+ start + afterMonth +' al '+ end +' de '+month+', '+year); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks