How to generate date in credit/debit card expiry date format?
P粉147747637
P粉147747637 2024-03-31 20:06:54
0
2
412

I need to generate a date in 'Thru: 12/20' format (like credit/debit card expiration date format). What is the best way to generate a date in this format?

new Date().toJSON().slice(0,7).split('-').reverse().join('/')

I am getting the date in mm/yyyy format but cannot get the desired result

P粉147747637
P粉147747637

reply all(2)
P粉826283529

Using Moment, you can simply do the following:

const date = moment().format("ddd DD/MM");
console.log("Valid until : " + date);
sssccc
P粉094351878

You can use Intl.DateTimeFormat to generate a date in date name and dd/MM format

const options = { weekday: 'short', month: 'numeric', day: 'numeric' };
const result = new Intl.DateTimeFormat('en-GB', options).format(new Date());
console.log(result);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!