simple time question...

Results 1 to 2 of 2

Thread: simple time question...

  1. #1
    mykull Guest

    Default simple time question...

    What is the syntax in javascript to get the current TIME from the client and have it formatted in a legible (readable like HH:MM:SS AM/PM) format? help!!

  2. #2
    Dan Evans Guest

    Default RE: simple time question...

    This ought to do it:<BR><BR>var d = new Date().toString();<BR>var t = d.substring(d.indexOf(":") - 2, d.lastIndexOf(":") + 3);<BR>t += t.substring(0, 2) &#060; 12? " am": " pm";<BR>document.write(t);<BR><BR>It grabs the full date string and then checks for the colons, using them to pull out the time. Then adding am/pm on the end.<BR><BR>Hope this helps,<BR><BR>-Dan Evans

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts