blondebier
Programmer
I'd like to display the current date/time on a website. Does anyone know how I can do this in a HTML page?
Cheers for any help.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<html>
<head>
<script type="text/javascript">
dayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
monName = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
dateExt = new Array ("","st","nd","rd","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","st","nd","rd","th","th","th","th","th","th","th","st");
var today = new Date();
var _dateString = dayName[today.getDay()] + ", " + monName[today.getMonth()] + " " + today.getDate() + dateExt[today.getDate()];
var _timeString = today.getHours() + "h " + today.getMinutes() + "m " + today.getSeconds() + "s";
</script>
</head>
<body>
<script type="text/javascript">document.write(_dateString + " (" + _timeString + ").");</script>
</body>
</html>