Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

370
Views
How to generate date in the format of credit/debit card expiry date?

I have a requirement of generating dates in this format 'Thru: 12/20' (like credit/debit card expiry date format). What is the best way of generating date in this format?

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

I got the date in mm/yyyy format but couldn't get the desired result

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can use Intl.DateTimeFormat to generate date in day 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);

about 4 years ago · Juan Pablo Isaza Report

0

With Moment you can simply do:

const date = moment().format("ddd DD/MM");
console.log("Valid until : " + date);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!