Welcome to WebmasterServe!

FREE TO JOIN! Join us now to engage in informative and friendly discussions about Webmastering, SEO, SEM, Internet Marketing, Programming, Graphic Design, Online Jobs and more. What are you waiting for? Ready to join our friendly community? It takes just one minute to register.

Dismiss Notice

Join WebmasterServe Forums 
Join the discussion! Have a better idea or an opinion? It takes just one minute to register Click Here to Join

My 2 Cents Here is working and corrected script for showing current date on website

Discussion in 'Javascript and jQuery' started by richardm55, Jul 1, 2012.

Thread Status:
Not open for further replies.
  1. richardm55

    White Belt

    Joined:
    Jul 1, 2012
    Messages:
    3
    Ratings:
    +0 / -0
    Some time ago I have found script for showing present date on website. It worked properly for Mozilla but not for IE so I have corrected it. And here is below:

    DayName = new Array(7)
    DayName[0] = "Sunday "
    DayName[1] = "Monday "
    DayName[2] = "Tuesday "
    DayName[3] = "Wednesday "
    DayName[4] = "Thursday "
    DayName[5] = "Friday "
    DayName[6] = "Saturday "
    MonthName = new Array(12)
    MonthName[0] = "January "
    MonthName[1] = "February "
    MonthName[2] = "March "
    MonthName[3] = "April "
    MonthName[4] = "May "
    MonthName[5] = "June "
    MonthName[6] = "July "
    MonthName[7] = "August "
    MonthName[8] = "September "
    MonthName[9] = "October "
    MonthName[10] = "November "
    MonthName[11] = "December "
    function getDateStr(){
    var Today = new Date()
    var WeekDay = Today.getDay()
    var Month = Today.getMonth()
    var Day = Today.getDate()
    var Year = Today.getFullYear()
    return DayName[WeekDay] + "," + " " + Day + " " + MonthName[Month] + ", " + Year
    }

    As you know you can insert this script either in head section using script tag or in external js file
    While in body section in place you want the date to appear you will write down this html code: <script language="JavaScript">document.write("Today is " + getDateStr())</script>

    I hope this code will be helpful for some people.
     
  2. Marklen

    Banned

    Joined:
    Jul 16, 2012
    Messages:
    19
    Ratings:
    +0 / -0
    The coding is perfect , it will be very well useful, can you tell which editor you use for coding pupose
     
  3. laknaa

    White Belt

    Joined:
    Sep 13, 2012
    Messages:
    3
    Ratings:
    +0 / -0
    It used java script right?
    Do you have any php scripts?
     
Thread Status:
Not open for further replies.

Share This Page