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粉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
P粉0943518782024-04-01 11:17:37
You can use Intl.DateTimeFormat
< /a> 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);