The JScript "getYear" does not work in Mozilla ? :-)))

A

Alex Nitulescu

Hi. I have a header implemented as a user control (ascx). On start-up, I
show the date/time (in a label named "lblTimer") like this:

<html>
.......
<span....
<%=Now.ToShortDateString() %> - <%=ctype(Now.ToLongTimeString(),
datetime).tostring("H:mm:ss tt") %>
</span>

Then, I have a JavaScript block which refreshes the clock every second - and
the main function is:
____________________________________________________________________________
function ClockRefresh(){

var dtDate=new Date();
var strAMPM="AM";
var intHours=dtDate.getHours();
var str = "";

str += (dtDate.getMonth() + 1) + "/";
str += dtDate.getDate() + "/";
str += dtDate.getYear();

if(intHours>12){
intHours-=12;
strAMPM="PM";
}

var intMinutes=dtDate.getMinutes() + "";
if(intMinutes.length==1){
intMinutes="0" + intMinutes;
}

var intSeconds=dtDate.getSeconds() + "";
if(intSeconds.length==1){
intSeconds="0" + intSeconds;
}

lblTimer.innerHTML=str + " - " + intHours + ":" + intMinutes + ":" +
intSeconds + " " + strAMPM;
}
____________________________________________________________________________

In IE everything is fine. In Mozilla, however, it starts for instance as
2/24/2005 - 1:06:48 AM
but the next second, when ClockRefresh executes, I get
2/24/105 - 1:06:49 AM

There is a 1900 years difference between the JScript getYear in Mozilla and
the one in IE !

Thank you, Alex.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top