Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

set a previous year to the current date in javascript

const d = new Date();
d.setFullYear(d.getFullYear()-1);

console.log(d.toDateString()); // "Fri Oct 04 2019"
Comment

get previous year in javascript

const currentYear = new Date().getFullYear(); // 2020

const previousYear =  currentYear-1;

console.log(previousYear); // 2019
Comment

PREVIOUS NEXT
Code Example
Javascript :: js create element from string 
Javascript :: random in a range js 
Javascript :: json fetch data doest show 
Javascript :: javascript get json keys 
Javascript :: angular router.navigate pass data 
Javascript :: javascript explode 
Javascript :: unpack list javascript 
Javascript :: js date subtract days 
Javascript :: javascript remove a specific item from an array 
Javascript :: nl2br in jquery 
Javascript :: ajax authorization header token 
Javascript :: how to register key presses in p5.js 
Javascript :: javascript decimal to string 
Javascript :: asp.net core 3.1 convert system.collections.generic.list`1[system.string] to javascript 
Javascript :: use local storage on server with node 
Javascript :: javascript get second last element in array 
Javascript :: express js server 
Javascript :: js sort ascendign 
Javascript :: vue data 
Javascript :: javascript to help find overflow elements 
Javascript :: How to fix CSS & JS not loading issue in cPanel laravel 
Javascript :: useHistory react-router-dom 
Javascript :: react js empty build 
Javascript :: JS get min date 
Javascript :: js enter key event listener 
Javascript :: how to find length of array js 
Javascript :: js keydown only once 
Javascript :: back button next js 
Javascript :: ciclo for javascript 
Javascript :: check if array has same values javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =