Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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 :: how to access dictionary keys in js 
Javascript :: how to make back button react 
Javascript :: make form submit on new tab using jquery 
Javascript :: javaScript setSeconds() Method 
Javascript :: node.js util module 
Javascript :: change key name in array of objects javascript 
Javascript :: angular pipe percentage 
Javascript :: vuejs cant add script in template 
Javascript :: jquery find index of this 
Javascript :: how to make a div appear onclick 
Javascript :: javascript document.createElement add function 
Javascript :: window load 
Javascript :: set node_env in windows 
Javascript :: nuxt query params 
Javascript :: node express app.listen at specific port & host 
Javascript :: jquery div onload function 
Javascript :: this setstate previous state react 
Javascript :: vue 3 script setup dynamic component sample 
Javascript :: javascript fs write file with folder 
Javascript :: javascript iterate over map keys 
Javascript :: promise all then 
Javascript :: react render after data loaded 
Javascript :: indexof method javascript 
Javascript :: form submit event get button 
Javascript :: node js on macbook m1 
Javascript :: usereducer example 
Javascript :: how to export a constant in javascript 
Javascript :: electron new window 
Javascript :: node js response header 
Javascript :: Node Sass version 7.0.0 is incompatible with ^4.0.0 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =