Skip to content

Instantly share code, notes, and snippets.

@mallendeo
Created February 9, 2014 18:22
Show Gist options
  • Save mallendeo/8903557 to your computer and use it in GitHub Desktop.
Save mallendeo/8903557 to your computer and use it in GitHub Desktop.
Get start and end of week with Momentjs
// 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);
});
@milad-kamali
Copy link

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment