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.
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.