import moment from 'moment'; const expiryDate = '03-21-2023'; const currentDate = moment(); // Parse the expiry date using Moment.js const parsedExpiryDate = moment(expiryDate, 'MM-DD-YYYY'); // Compare the expiry date to the current date to check if the token is expired if (parsedExpiryDate.isBefore(currentDate)) { console.log('Token has expired!'); } else { console.log('Token is still valid'); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter