Where can I get free ASP code for a clock with only hh:ss AM/PM ?

Posted on 2006-03-25
Last Modified: 2012-05-05
Hi Experts,

Where can I get free ASP code for a clock with only hh:ss AM/PM ?

Question by:indyng
    LVL 75

    Expert Comment

    by:Anthony Perkins
    Again you have three options:
    1. Hope the Regional Settings are set correctly on the server and use something like this: FormatDateTime(Now(), vbLongTime)
    2. Write a function to output in the format you need.
    3. Use ASP.NET

    For option 2, see the code I posted in your related question:
    LVL 75

    Expert Comment

    by:Anthony Perkins
    In case you could not figure it out here it is:

    Function GetCurrentTime()
    Dim Dat, AMPM

    Dat = Now()

    If Hour(Dat) < 12 Then
          AMPM = " AM"
          AMPM = " PM"
    End If

    GetCurrentTime = LPad((Hour(Dat) - 1) Mod 12 + 1) & ":" & LPad(Minute(Dat)) & AMPM

    End Function

    Function LPad(ByVal Value)

    LPad = Right("0" & CStr(Value), 2)

    End Function
    LVL 33

    Accepted Solution

    Or are you want to use JavaScript?



    <script language="JavaScript">

    Live Date Script-

    var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
    var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

    function getthedate(){
    var mydate=new Date()
    var year=mydate.getYear()
    if (year < 1000)
    var day=mydate.getDay()
    var month=mydate.getMonth()
    var daym=mydate.getDate()
    if (daym<10)
    var hours=mydate.getHours()
    var minutes=mydate.getMinutes()
    var seconds=mydate.getSeconds()
    var dn="AM"
    if (hours>=12)
    if (hours>12){
    if (hours==0)
    if (minutes<=9)
    if (seconds<=9)
    //change font size here
    var cdate="<small><font color='000000' size='1' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
    //if (document.all)
    //if (!document.all)
    function goforit(){
    //if (document.all)



    <body onload="goforit()">
    <span id="clock"></span>



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
    Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now