SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Nov 2000
    Posts
    740
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Displaying the month

    I want to display the current month on my webpage like this:

    Month: February 2007

    How can I do that with javascript?

    Thanks,

    Jon


  2. #2
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    function getMonthName(){
    var D=new Date();
    var monthnames=['January','February','March','April','May','June', 'July','August','September','October','November','December'],
    return 'Month: '+monthnames[D.getMonth()]+', '+D.getFullYear();
    }

    Append the string in a text node to a heading or other element on your page, after it loads,
    or use document.write (with html tags) somewhere in the body while it is loading.

  3. #3
    SitePoint Guru
    Join Date
    Nov 2000
    Posts
    740
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do I put the function in the page header? Do I put something around it to say its javascript? I don't know javascript at all, only some php.

  4. #4
    SitePoint Zealot dawgbone's Avatar
    Join Date
    Dec 2003
    Location
    Brampton
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jon Lawrance View Post
    Do I put the function in the page header? Do I put something around it to say its javascript? I don't know javascript at all, only some php.
    <script language = "javascript">

    Code goes here

    </script>


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
  •