Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Get First Day and last day of week javascript

var curr = new Date; // get current date
var first = curr.getDate() - curr.getDay(); // First day is the day of the month - the day of the week
var last = first + 6; // last day is the first day + 6

var firstday = new Date(curr.setDate(first)).toUTCString();
var lastday = new Date(curr.setDate(last)).toUTCString();

firstday
"Sun, 06 Mar 2011 12:25:40 GMT"
lastday
"Sat, 12 Mar 2011 12:25:40 GMT"
Comment

javascript first and last day of the month

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

js get first and last day of previous month

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      
Comment

PREVIOUS NEXT
Code Example
Javascript :: c3 json from string 
Javascript :: running shell commands javascript 
Javascript :: yup email validation 
Javascript :: get height of div use js 
Javascript :: check if date time string is invalid date js 
Javascript :: javascript get weekday name 
Javascript :: Appium click on element Javascript 
Javascript :: how to get tomorrow date in javascript 
Javascript :: random number javascript 
Javascript :: javascript check if string is json parsable 
Javascript :: how to reload the same page using javascript 
Javascript :: javascript get scroll position 
Javascript :: bootstrap show modal on page load 
Javascript :: chart js hide legend 
Javascript :: socket io with cors 
Javascript :: js start with 
Javascript :: copy text to clipboard javascript 
Javascript :: moment remove one day 
Javascript :: jquery body class add 
Javascript :: send a file ajax 
Javascript :: react bootstrap styles not working 
Javascript :: add classnames to body 
Javascript :: javascript disable scrolling on body 
Javascript :: vue deep watch 
Javascript :: ReactDOM.render is no longer supported in React 18. Use createRoot instead 
Javascript :: javascript reduce function to get sum of object value 
Javascript :: generate jwt secret key 
Javascript :: remove tr in table jquery 
Javascript :: nativeelement angular add class 
Javascript :: nodejs ask for input 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =