ADVERTISEMENT

JavaScript Program to show Date and Time Stamp

ADVERTISEMENT

This is a simple JavaScript Program to show Date and Time Stamp. With this script, you can have the date and time the page was loaded ‘stamped’ to the page. This would make a wonderful header or footer for any web page.

Many people confuse about JavaScript array [] and object {}, so this tutorial will explain the difference in between JavaScript {} and []

<!-- 

ONE STEP TO INSTALL DATE & TIME STAMP: 
1. Paste the coding into the BODY of your HTML document 

-->

<!-- STEP ONE: Copy this code into the BODY of your HTML document -->

<script language="JavaScript">

<!-- This script and many more are available online from -->
<!-- The JavaScript Source!! http://javascriptsource.com -->

<!-- Begin
Stamp = new Date();
document.write('<b>' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+Stamp.getYear() + '</b><br />');
var Hours;
var Mins;
var Time;
Hours = Stamp.getHours();
if (Hours >= 12) {
 Time = " P.M.";
}
else {
 Time = " A.M.";
}
if (Hours > 12) {
 Hours -= 12;
}
if (Hours == 0) {
 Hours = 12;
}
Mins = Stamp.getMinutes();
if (Mins < 10) {
 Mins = "0" + Mins;
}
document.write('<font size="2" face="Arial"><b>' + Hours + ":" + Mins + Time + '</b></font>');
// End -->
</script>

<!-- Script Size: 0.97 KB -->

 

ADVERTISEMENT
M. Saqib: Saqib is Master-level Senior Software Engineer with over 14 years of experience in designing and developing large-scale software and web applications. He has more than eight years experience of leading software development teams. Saqib provides consultancy to develop software systems and web services for Fortune 500 companies. He has hands-on experience in C/C++ Java, JavaScript, PHP and .NET Technologies. Saqib owns and write contents on mycplus.com since 2004.
Related Post