Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get only last 2 digit of year in javascript

var strDate = new Date(); // By default Date empty constructor give you Date.now
var shortYear = strDate.getFullYear(); 
// Add this line
var twoDigitYear = shortYear.toString().substr(-2);
Comment

get last two digits of year javascript

 maskDate(date) {
    // console.log(date);
    var dateVar = new Date(date);
    // console.log("XX/XX/"+ dateVar.getFullYear().toString().substr(-2));
    return "XX/XX/"+ dateVar.getFullYear().toString().substr(-2);
 }
Comment

js get current year last 2 digits substring

//new 
const date = new Date("01/20/2021"); // 20th January 2021
const year = date.getFullYear(); // 2021

const year2digits = year.toString().substring(2);

console.log(year2digits); // "21"
Comment

PREVIOUS NEXT
Code Example
Javascript :: app.use public 
Javascript :: javascript localstorage 
Javascript :: readfile nodejs 
Javascript :: regex to check if text is in quotations 
Javascript :: js addeventlistener arrow keys 
Javascript :: Get LocalStorage from WebView react native 
Javascript :: gsap pin scrolltrigger 
Javascript :: accept Post with no midleWare express 
Javascript :: Cookies In NodeJS 
Javascript :: angular findindex object based array 
Javascript :: using dto in node js 
Javascript :: array sort by two properties 
Javascript :: cancel axios request 
Javascript :: float to currency js 
Javascript :: javascript random number generator 
Javascript :: regex valid url 
Javascript :: js get last element of array 
Javascript :: reset input react 
Javascript :: number round 
Javascript :: node js cross origin error 
Javascript :: Error: Unable to resolve module ./index from 
Javascript :: jquery datatable checkbox checked row data 
Javascript :: js Float32Array to percentage 
Javascript :: input radio trigger select jquery 
Javascript :: is a letter javascript 
Javascript :: string compare on date in js 
Javascript :: pipe data to json angular 
Javascript :: javascript destructure object and rename 
Javascript :: view my password jquery 
Javascript :: active js 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =