Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

moment get week


const currentWeekNumber = moment().week()

const weekNumberFromDay = moment('yyyy-mm-dd').week()
Comment

moment get start of week in datetime

const today = moment();
const from_date = today.startOf('week');
const to_date = today.endOf('week');
console.log({
  from_date: from_date.toString(),
  today: moment().toString(),
  to_date: to_date.toString(),
});

// {
//   from_date: "Sun Apr 22 2018 00:00:00 GMT-0500",
//   today: "Thu Apr 26 2018 15:18:43 GMT-0500",
//   to_date: "Sat Apr 28 2018 23:59:59 GMT-0500"
// }
Comment

moment js get last week start and end date

console.log(moment().subtract(1, 'weeks').startOf('isoWeek').format('dddd'));
console.log(moment().subtract(1, 'weeks').endOf('isoWeek').format('dddd'));

console.log(moment().subtract(1, 'weeks').startOf('week').format('dddd'));
console.log(moment().subtract(1, 'weeks').endOf('week').format('dddd'));

console.log(moment().subtract(1, 'weeks').startOf('week').format('YYYY-MM-DD'));
console.log(moment().subtract(1, 'weeks').endOf('week').format('YYYY-MM-DD'));
Comment

PREVIOUS NEXT
Code Example
Javascript :: react router dom v6 active link 
Javascript :: bootstrap datepicker set min and max date 
Javascript :: how to add custom font to react project 
Javascript :: check jquery page 
Javascript :: jquery map 
Javascript :: event delegation in javascript 
Javascript :: display content in a modal react 
Javascript :: add query parameter to url react router v6 
Javascript :: react app js 
Javascript :: using multiparty with node js express 
Javascript :: es6 iife 
Javascript :: @input and @output in angular 
Javascript :: js check if function is a constructor 
Javascript :: npm add latest version to package json 
Javascript :: react native keyboard event listener 
Javascript :: json placholder 
Javascript :: join a list of strings into one string javascript 
Javascript :: get version from package.json 
Javascript :: two sum javascript solution 
Javascript :: javascript remove first character from array list 
Javascript :: npm react copy to clipboard 
Javascript :: javascript replace array element 
Javascript :: Group array of strings by first letter 
Javascript :: formik react native 
Javascript :: jquery form serialize object 
Javascript :: get bottom position of element javascript 
Javascript :: get data attribute javascript 
Javascript :: query string from object js 
Javascript :: javascript inject html 
Javascript :: js how to work with float 2 decimal numbers 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =