1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

JavaScript Add a date to your page

Discussion in 'Web Development' started by ishkey, Oct 18, 2008.

  1. ishkey

    ishkey Moderator, Logos, Sports Crests Staff Member Verified Member

    Add this javascript anywhere on the page you want todays date to show. If you just want to see how it looks, copy the entire code and save it as date.html, then open it with your browser.
    <?xml version="1.0" encoding="windows-1252"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    <html xmlns="http://www.w3.org/1999/xhtml">
    <!-- Created on: 10/15/2008 -->
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    var now = new Date();
    var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
    var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
    var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
    function fourdigits(number) {
    return (number < 1000) ? number + 1900 : number;
    today = days[now.getDay()] + ", " +
    months[now.getMonth()] + " " +
    date + ", " +
    (fourdigits(now.getYear())) ;
    // End -->
  2. pezboy45

    pezboy45 Mod/Design & Coder [Pro]

    I am actually going to use this....
    Right now.
    Thanks a bunch.