SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I realize it's been done, but I couldn't find just what I needed so I wrote my own. And I'm sharing it if any is interested.

    Code:
    <!-- Inserts day, month, date, and time of day -->
    <!-- Use DIV tags around code to define output -->
    <!-- This code was written by Steve Olson -->
    <!-- Free to use if you leave these comment lines in -->
    <Script language=javascript type="text/javascript">
    <!-- Hide 
    currentDate = new Date
    currentDay = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
    currentMonth = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
    if (currentDate.getHours() > 0 && currentDate.getHours() < 13)  {
       currentHour = currentDate.getHours()
    } else  {
        if (currentDate.getHours() == 0)	{
        currentHour = 12
        } else  {
          currentHour = currentDate.getHours() - 12
          }
    }
    if (currentDate.getMinutes() < 10)	{
       currentMin = "0" + currentDate.getMinutes()
       } else  {
         currentMin = currentDate.getMinutes()
    }
    if (currentDate.getHours() >= 0 && currentDate.getHours() < 12)  {
       amPm = "am"
    }  else  {
    amPm = "pm"
    }
    document.write(currentDay[currentDate.getDay()] + ", " + currentMonth[currentDate.getMonth()] + " " + currentDate.getDate() + "&nbsp;&nbsp;" + currentHour + ":" + currentMin + " " + amPm)
    // -->
    </Script>
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Westmich,

    Took a quick glance, and except for one typo

    currentDate = new Date();

    looks good

    Isn't it nice creating something?

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


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
  •