Need some help please - simple for you Guru's :)

Discussion in 'JavaScript' started by worlddomain, Nov 14, 2008.

  1. #1
    I have this javascript date code which shows the day and date all on one line

    I need to have it show on two lines - so the top line shows the day and the line below shows the date

    Like this

    Original:

    Friday, November 14, 2008

    What I need:
    Friday
    November 14, 2008

    This is the code:


    <!--Place this script anywhere in a page.-->
    <!--NOTE: You do not need to modify this script.-->
    
    <SCRIPT language="JavaScript" type="text/javascript">
    <!--
    // current date - from http://rainbow.arch.scriptmania.com/scripts
    // Array of day names
    var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
    
    var monthNames = new Array("January","February","March","April","May","June","July",
                               "August","September","October","November","December");
    
    var dt = new Date();
    var y  = dt.getYear();
    
    // Y2K compliant
    if (y < 1000) y +=1900;
    
    document.write(dayNames[dt.getDay()]+ ", " + monthNames[dt.getMonth()] + " " + dt.getDate() + ", " + y );
    // -->
    </SCRIPT>
    Code (markup):
    Thanks
     
    worlddomain, Nov 14, 2008 IP
  2. rene7705

    rene7705 Peon

    Messages:
    233
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    document.write(dayNames[dt.getDay()]+ "<br/>" + monthNames[dt.getMonth()] + " " + dt.getDate() + ", " + y );
     
    rene7705, Nov 14, 2008 IP
    worlddomain likes this.
  3. worlddomain

    worlddomain Well-Known Member

    Messages:
    1,138
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Thanks rene7705,

    I had originally tried the <br/> but with the "" lol.... now I know better :)

    Cheers.. rep added.
     
    worlddomain, Nov 14, 2008 IP