Results 1 to 3 of 3

Thread: How to add a date to my page using Javascript ?

  1. #1
    Join Date
    Feb 2009
    Posts
    64

    How to add a date to my page using Javascript ?

    hie,

    I want to ask how can I add a date to my page using a Javascript. Does anyone knows how to do this..... please help

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: To add a date to your page using Javascript

    Add this javascript anywhere on the page to see today's date on the page.



    Code:
    <?xml version="1.0" encoding="windows-1252"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <!-- Created on: 10/15/2008 -->
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
    <title></title>
    </head>
    <body>
    <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())) ;
    document.write(today);
    // End -->
    </script>
     
    </body>
    </html>

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to add a date to my page using Javascript ?

    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.

Similar Threads

  1. Firefox 3 full page zoom from javascript
    By HeerePanna in forum Software Development
    Replies: 4
    Last Post: 21-09-2010, 06:52 AM
  2. Date Object In Javascript
    By Level8 in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 12:07 PM
  3. How to find out Current Page Url with the help of JavaScript?
    By Kushan in forum Software Development
    Replies: 3
    Last Post: 21-11-2009, 10:40 AM
  4. How to add WMV video file to web page using JavaScript
    By KAILEY in forum Software Development
    Replies: 3
    Last Post: 31-08-2009, 07:49 PM
  5. JavaScript code outside html page
    By Gefry in forum Software Development
    Replies: 3
    Last Post: 30-04-2009, 03:53 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,715,936.75485 seconds with 17 queries