get last 2 digits of year javascript code example
Example 1: js get last 4 digits
const id = "ctl03_Tabs1";
console.log(id.slice(id.length - 5));
console.log(id.slice(id.length - 1));
Example 2: get only last 2 digit of year in javascript
var strDate = new Date();
var shortYear = strDate.getFullYear();
var twoDigitYear = shortYear.toString().substr(-2);
Example 3: get last two digits of year javascript
maskDate(date) {
var dateVar = new Date(date);
return "XX/XX/"+ dateVar.getFullYear().toString().substr(-2);
}