search

Home  >  Q&A  >  body text

How to generate date in credit/debit card expiry date format?

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粉147747637P粉147747637266 days ago514

reply all(2)I'll reply

  • P粉826283529

    P粉8262835292024-04-01 14:01:01

    Using Moment, you can simply do the following:

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

    reply
    0
  • P粉094351878
  • Cancelreply