Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

day of week javscript

const weekday = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];

const d = new Date();
let day = weekday[d.getDay()];
alert(day);
Comment

javascript get current week number

function weekNumber(date = new Date())
{
  var firstJanuary = new Date(date.getFullYear(), 0, 1);
  var dayNr = Math.ceil((date - firstJanuary) / (24 * 60 * 60 * 1000));
  var weekNr = Math.ceil((dayNr + firstJanuary.getDay()) / 7);
  return weekNr;
}
Comment

javascript get date of the week

//Grab day of the week from local computer
let date = new Date();
let dayOfWeekNumber = date.getDay();
let nameOfDay;
let quote;

switch(dayOfWeekNumber){
    case 0: 
        nameOfDay = 'Sunday';
        quote = 'Time to chillax!';
        break;
    case 1:
        nameOfDay = 'Monday';
        quote = 'Monday morning blues!';
        break;
    case 2:
        nameOfDay = 'Tuesday';
        quote = 'Taco Time!';
        break;
    case 3:
        nameOfDay = 'Wednesday';
        quote = 'Two more days to the weekend.';
        break;
    case 4:
        nameOfDay = 'Thursday';
        quote = 'The weekend is almost here...';
        break;
    case 5:
        nameOfDay = 'Friday';
        quote = 'Weekend is here!';
        break;
    case 6:
        nameOfDay = 'Saturday';
        quote = 'Time to party!';
        break;

}
//Display the day of the week
let weekdayDiv = document.getElementById('weekday');
weekdayDiv.innerHTML = `${nameOfDay}`;

//Display quote
let quoteDiv = document.getElementById('phrase');
quoteDiv.innerHTML = `${quote}`


Comment

get date one week from now javascript

function nextweek(){
    var today = new Date();
    var nextweek = new Date(today.getFullYear(), today.getMonth(), today.getDate()+7);
    return nextweek;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript array concat spread operator 
Javascript :: npm uniqueid 
Javascript :: regExp numero français 
Javascript :: insert data from lambda to dynamodb 
Javascript :: MDB React Bootstrap Import 
Javascript :: javascript write all the prime numbers from 1 to 100 
Javascript :: prevent form submission on onsubmit function calls 
Javascript :: replace all occurrences of a string in javascript 
Javascript :: aws list all files in s3 bucket node js aws 
Javascript :: how to run curl in javascript 
Javascript :: material ui location icon 
Javascript :: document.getElementByClass is not a function 
Javascript :: datatables dynamically hide columns 
Javascript :: button onclick enter key 
Javascript :: usestate remove from array 
Javascript :: android force date inside RecyclerView to re render 
Javascript :: remove event listener jquery 
Javascript :: To split a full name into first and last names in JavaScript 
Javascript :: node js variables in string 
Javascript :: js convert html to text 
Javascript :: play audio with js 
Javascript :: any click event jquery 
Javascript :: gulp runSequence 
Javascript :: moment timezone get timezone offset 
Javascript :: jquery event keycode 
Javascript :: js get parameters 
Javascript :: ant design table sort string perfectly 
Javascript :: removeclass multiple 
Javascript :: regex match line that does not contain string 
Javascript :: check value exist in array javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =