Tuesday, March 13, 2012

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

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."Alex Nitulescu" <REMOVETHIScuca_macaii2000@.yahoo.com> wrote in message
news:u54CugjGFHA.1392@.TK2MSFTNGP10.phx.gbl...

> There is a 1900 years difference between the JScript getYear in Mozilla
> and the one in IE !
Try getFullYear() instead...
http://www.quirksmode.org/js/datecompat.html
Thanks, it works fine now !
"Mark Rae" <mark@.mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:%23ljNzbkGFHA.3068@.tk2msftngp13.phx.gbl...
> "Alex Nitulescu" <REMOVETHIScuca_macaii2000@.yahoo.com> wrote in message
> news:u54CugjGFHA.1392@.TK2MSFTNGP10.phx.gbl...
>
> Try getFullYear() instead...
> http://www.quirksmode.org/js/datecompat.html
>

0 comments:

Post a Comment