javascript get current month start and end date
var date = new Date();
var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
javascript get current month start and end date
var date = new Date();
var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
javascript month name
let date = new Date(2020, 05, 21); // 2020-06-21
let longMonth = date.toLocaleString('en-us', { month: 'long' }); /* June */
let shortMonth = date.toLocaleString('en-us', { month: 'short' }); /* Jun */
let narrowMonth = date.toLocaleString('en-us', { month: 'narrow' }); /* J */
Javascript get month name
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var d = new Date();
var monthName=months[d.getMonth()]; // "July" (or current month)
javascript get month name from number
export const GetDatMonthFromDate=(dateSplit:any)=>{
dateSplit = dateSplit.split('-');
var monthShortNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
];
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
const date = new Date(dateSplit[0], dateSplit[1], dateSplit[2]); // 2020-06-21
return dateSplit[2]+' '+ monthShortNames[date.getMonth()];
}
GetDatMonthFromDate('2021-07-2');
//output = 2 sep;
// if you wanty full month then use months instead of monthShortNames on
// line number 9
//return dateSplit[2]+' '+ months[date.getMonth()]; output == 2 September
javascript getmonth
new Date().getMonth(); //note that Jan=0, Dec=11 (annoying I know)
how to get only month and year in js
let dateObj = new Date();
let myDate = (dateObj.getUTCFullYear()) + "/" + (dateObj.getMonth() + 1)+ "/" + (dateObj.getUTCDate());
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