“JavaScript obtenga el primer día del mes y el último día” Código de respuesta

Javascript Fecha del primer día del mes actual

var date = new Date();
var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
Ham-Solo

JavaScript obtenga fecha de inicio y finalización del mes actual

var date = new Date();
var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
HossAzadi

JS consigue el primer y último día del mes anterior

var d = new Date();
d.setDate(0); //sets d to the last day of the previous month
d.setDate(1); //sets d the the first day of that month
d.setHours(0,0,0,0); //sets d time to midnight

//d now equals the first day of the month before today      
Lazy Lemur

JavaScript obtenga el primer día del mes y el último día

var lastday = function(y,m){
return  new Date(y, m +1, 0).getDate();
}
console.log(lastday(2014,0));
console.log(lastday(2014,1));
console.log(lastday(2014,11));
Victorious Vulture

Respuestas similares a “JavaScript obtenga el primer día del mes y el último día”

Preguntas similares a “JavaScript obtenga el primer día del mes y el último día”

Más respuestas relacionadas con “JavaScript obtenga el primer día del mes y el último día” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código