Skip to content

Instantly share code, notes, and snippets.

@tkh44
Created August 12, 2013 20:34
Show Gist options
  • Save tkh44/6214896 to your computer and use it in GitHub Desktop.
Save tkh44/6214896 to your computer and use it in GitHub Desktop.
moment is beautiful
updateDateInputValues: function(e) {
var $start = $(e.currentTarget),
$end = $('input[name="endDate"]'),
startDate = moment($start.val(),'YYYY-MM-DD'),
endDate = moment($end.val(), 'YYYY-MM-DD');
while(endDate.isBefore(startDate) || endDate.isSame(startDate)) {
endDate.add('d', 1);
}
$end.val(endDate.format('YYYY-MM-DD'));
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment