//Date let now = new Date(); //will give you the full date now.getMilliseconds(); now.getSeconds(); now.getMinutes(); now.getHours(); now.getDate(); // number date of month now.getDay(); //day of the week 0=sunday now.getMonth();//january = 0 now.getFullYear(); //example of getting the current date to show up as h2 let now = new Date(); let h2 = document.querySelector("h2"); let daysOfWeek = ["Sun", "Mon", "Tue", "Wed", "Thurs", "Fri", "Sat"] let date = now.getDate(); let day = daysOfWeek [now.getDay()]; let year = now.getFullYear(); let hours = now.getHours(); let minutes = now.getMinutes(); let monthsOfYear = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "July", "Aug", "Sept", "Oct", "Nov", "Dec"] let month = monthsOfYear[now.getMonth()]; h2.innerHTML = `${day} ${month} ${date}, ${hours}:${minutes}, ${year}`;
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