'how to auto generate id like AB22020001 in nodejs

i want auto generate id like "DC" + yaer + mounth + 4 digit in nodejs.

I am using node js to create an api to connect to the database which I use phpmyadmin I want to create an id like AB22020001 But now all I can do is create an ID like AB2202. I don't know how to make the number after. My ID consists of 2 letters, last 2 digits of the year and month, and the other 4 digits run from 0001 to 9999. When a new month starts, the last 4 digits start counting at 00001 again.

in my code

let date_ob = new Date();
let year = date_ob.getFullYear();
let yaer_today = year.toString().substring(2)

let month = ("0" + (date_ob.getMonth() + 1)).slice(-2);

const ID = 'AB' + yaer_today + month
console.log(ID)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source