Date Time
function ShowDate() { const currentDate = new Date(); const currentMonth = currentDate.toLocaleString('en-US', { month: 'long' }); const currentDay = currentDate.getDate(); let daySuffix; switch (currentDay) { case 1: case 21: case 31: daySuffix = "st"; break; case 2: case 22: daySuffix = "nd"; break; case 3: case 23: daySuffix = "rd"; break; default: daySuffix = "th"; } const currentYear = currentDate.getFullYear(); return `${currentMonth} ${currentDay}${daySuffix} ${currentYear}`; }
- function ShowDate() {
- const currentDate = new Date();
const monthsOfYear = ["January","February","March","April","May","June","July","August","September","October","November","December",];const currentMonth = monthsOfYear[currentDate.getMonth()];- const currentMonth = currentDate.toLocaleString('en-US', { month: 'long' });
- const currentDay = currentDate.getDate();
- let daySuffix;
- switch (currentDay) {
- case 1:
- case 21:
- case 31:
- daySuffix = "st";
- break;
- case 2:
- case 22:
- daySuffix = "nd";
- break;
- case 3:
- case 23:
- daySuffix = "rd";
- break;
- default:
- daySuffix = "th";
- }
- const currentYear = currentDate.getFullYear();
- return `${currentMonth} ${currentDay}${daySuffix} ${currentYear}`;
- }