Adding the Date and Time to your Web Pages

11:12 am HTML

date time scriptHave you noticed how all internet marketing sites display the current day and time near the top?

One of the reasons for doing this is that it shows the reader the information is current (and not some old abandoned web page that is still online).

It’s easy to add this bit of information to your web site.  All you need to do is copy and paste a bit of javascript into your HTML where you’d like the date and time to appear.  After you paste the code into your web page and upload it to your server, the date and time will automatically update each day.

Feel free to copy and past the script below into your web pages (there’s no need to change it).

—————————

<script><!–

var mydate=new Date()

var year=mydate.getYear()

if (year < 1000)

year+=1900

var day=mydate.getDay()

var month=mydate.getMonth()

var daym=mydate.getDate()

var dayarray=new Array(”Sunday”,”Monday”,”Tuesday”,”Wednesday”,”Thursday”,”Friday”,”Saturday”)

var montharray=new Array(”January”,”February”,”March”,”April”,”May”,”June”,”July”,”August”,”September”,”October”,”November”,”December”)

document.write(”"+dayarray[day]+”, “+montharray[month]+” “+daym+”, “+year+”")

// –></script>

——————–

There’s no need to change any of the code above.  Just make sure your start copying  before <script> and end after </script>.

On most internet marketing web sites, this script is added between the <BODY> and </BODY> tags.   Click here for an example.

Leave a Comment

Your comment

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.