SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Apr 2002
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Newbie Date Question

    Does anyone have a simple script that will echo the current date properly on both IE and NS? Example:

    Sunday, April 21st 2002

    I would use PHP, but I don't want to rename my index.html file to index.php


    Thanks - TWST

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    theres probably a better method than this but it's all i can think of at the moment.

    PHP Code:

    <html>
    <
    body>
    <
    script>

    var 
    d=new Date()

    var 
    weekday    = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
    var 
    month    = new Array("Janary","February","March","April","May","June","July","August","September","October","November","December")
    var 
    getIT    = new Array('<sup>st</sup>''<sup>nd</sup>''<sup>rd</sup>''<sup>th</sup>');

    if    (
    d.getDate() == || d.getDate() == 21 || d.getDate() == 31)
        
    th getIT[0];
    else if (
    d.getDate() == || d.getDate() == 22 || d.getDate() == 32)
        
    th getIT[1];
    else if (
    d.getDate() == || d.getDate() == 23 || d.getDate() == 33)
        
    th getIT[2];
    else
        
    th getIT[3];

    '';
    w+= weekday[d.getDay()] + ", ";
    w+= d.getDate();
    w+= th " "
    w+= month[d.getMonth()] + " ";
    w+= d.getFullYear();

    document.write (w);
    </script>
    </body>
    </html> 


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
  •