//Get current date and time
var currentDate = new Date();
//Get current date and time and add +n hours. Acts as an expiration date
var expirationDate = new Date();
expirationDate.setHours(expirationDate.getHours() + 2);
//Check if date has expired
if (currentDate > expirationDate) {
return {
message: 'Expired'
}
}
//To get a 24 hour time
var date = new Date();
console.log(date.toLocaleString('en-GB'));
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