PDA

View Full Version : Clock and date HELP!!


Alquimio
04-28-2003, 06:19 PM
Hi here !!!
I am trying to add the date to a clock
but I only get it to show up like the example below...

1:06:32 PM

The code for the example above is below:
What can I do to make it look like this...

February 22, 2003 1:06:32 PM



<span id="liveclock">
</span>

<script language="JavaScript">
<!--
function show5(){
if (!document.layers&&!document.all&&!document.getElementById)
return

var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()

var dn="PM"
if (hours<12)
dn="AM"
if (hours>12)
hours=hours-12
if (hours==0)
hours=12

if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here to your desire
myclock="<font size='5' face='Arial' ><b><font size='1'>Current Time:</font></br>"+hours+":"+minutes+":"
+seconds+" "+dn+"</b></font>"
if (document.layers){
document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.close()
}
else if (document.all)
liveclock.innerHTML=myclock
else if (document.getElementById)
document.getElementById("liveclock").innerHTML=myclock
setTimeout("show5()",1000)
}

window.onload=show5
//-->
</script>

tamienne
04-28-2003, 09:46 PM
m=new Array("January","February","March","April","May","June","July","August","September","October","November","December");

day=Digital.getDate();
year=Digital.getYear();
if (year < 2000) year=year+1900;
todaysDate=m[Digital.getMonth()]+" "+ day+", "+year;


myclock="<font size='5' face='Arial' ><b><font size='1'>Current Time:</font><br />"+todaysDate + " " +hours+":"+minutes+":"
+seconds+" "+dn+"</b></font>"

beetle
04-28-2003, 10:23 PM
http://www.peterbailey.net/dhtml/datestamp.htm

tamienne
04-28-2003, 10:36 PM
Hey Beetle,

I got an error when going to the link...

beetle
04-28-2003, 10:48 PM
What browser are you using?

Any details on the error?

Arctic Fox
04-29-2003, 03:17 AM
You could try this:
http://www.angelfire.com/mo2/cbch21/TEST/Clock.html

tamienne
04-29-2003, 12:06 PM
Line: 134
Char: 3
Error: Unexpected quantifier
Code: 0
URL: http://www.peterbailey.net/dhtml/datestamp.htm

IE Ver: 5.00.3105.0106
Cipher: 128-bit

beetle
04-29-2003, 01:17 PM
:eek: Oh no! The IE5 regex error! :eek:

That's a problem with IE5.0, and not my script -- however, there's proably something I can do a tad bit different to get it working.

tamienne
04-29-2003, 01:26 PM
Sorry beetle,
I'd love to upgrade but i need to support ie 5.0 and need it to test :)

beetle
04-29-2003, 01:45 PM
Hey, I understand. I'll take another look at my script in a couple hours and see if I can find a regular expression that IE5 likes.

beetle
04-29-2003, 03:18 PM
Ehh, I'm none too sure that I can get this to work. I'll keep it on the back burner for a little bit, tho.

hrmmpmhrmp stupid IE hmhrprhphphmm :mad: