moment js add day
var new_date = moment(startdate, "DD-MM-YYYY").add(5, 'days');
moment js add day
var new_date = moment(startdate, "DD-MM-YYYY").add(5, 'days');
moment get list of dates by week number
var dateformat = "YYYY/MM/DD";
function getWeekDaysByWeekNumber(weeknumber)
{
var date = moment().isoWeek(weeknumber||1).startOf("week"), weeklength=7, result=[];
while(weeklength--)
{
result.push(date.format(dateformat));
date.add(1,"day")
}
return result;
}
console.log(getWeekDaysByWeekNumber())
console.log(getWeekDaysByWeekNumber(2))
console.log(getWeekDaysByWeekNumber(25))
momentjs get calendar week
$(document).ready(function(){
var weeknumber = moment("12-25-1995", "MM-DD-YYYY").week();
console.log(weeknumber);
});
get week number of month from date moment
function test(mJsDate){
var str = mJsDate.toLocaleString().substring(0, 3) +
" number " + Math.ceil(mJsDate.date() / 7) +
" of the month";
return str;
}
for(var i = 1; i <= 31; i++) {
var dayStr = "2014-01-"+ i;
console.log(dayStr + " " + test(moment(dayStr)) );
}
//examples from the console:
//2014-01-8 Wed number 2 of the month
//2014-01-13 Mon number 2 of the month
//2014-01-20 Mon number 3 of the month
//2014-01-27 Mon number 4 of the month
//2014-01-29 Wed number 5 of the month
get week number of month from date moment
function test(mJsDate){
var str = mJsDate.toLocaleString().substring(0, 3) +
" number " + Math.ceil(mJsDate.date() / 7) +
" of the month";
return str;
}
for(var i = 1; i <= 31; i++) {
var dayStr = "2014-01-"+ i;
console.log(dayStr + " " + test(moment(dayStr)) );
}
//examples from the console:
//2014-01-8 Wed number 2 of the month
//2014-01-13 Mon number 2 of the month
//2014-01-20 Mon number 3 of the month
//2014-01-27 Mon number 4 of the month
//2014-01-29 Wed number 5 of the month
moment get date by weeknumber
console.log(state.weeknumber)
console.log(state.created_at.clone().add(7, "day").format("Do MMMM"))
console.log(state.weeknumber)
console.log(moment().day("monday").week(value).format("Do MMMM"))
console.log(moment().day("tuesday").week(value).format("Do MMMM"))
console.log(moment().day("wednesday").week(value).format("Do MMMM"))
console.log(moment().day("thursday").week(value).format("Do MMMM"))
console.log(moment().day("friday").week(value).format("Do MMMM"))
console.log(moment().day("saturday").week(value).format("Do MMMM"))
console.log(moment().day("sunday").week(value).add(7, "day").format("Do MMMM"))
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us