“Momento Get Week” Código de respuesta

Momento Obtenga el nombre del día de la semana

var m = moment().day(); // gives 4 for thursday, then you can do a switch
GutoTrosla

Momento Obtenga el número de la semana ISO

const weekNumber = moment().format("w");
Jash_World

Momentjs obtiene la semana calendario

  $(document).ready(function(){
    var weeknumber = moment("12-25-1995", "MM-DD-YYYY").week();
    console.log(weeknumber);
  });
Different Dunlin

Momento Comienza la semana en 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"
// }
Foolish Flatworm

Obtenga la semana número de mes desde el momento de la fecha

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
Agreeable Angelfish

Momento Get Week


const currentWeekNumber = moment().week()

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

Respuestas similares a “Momento Get Week”

Preguntas similares a “Momento Get Week”

Más respuestas relacionadas con “Momento Get Week” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código