473,398 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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.
Nov 19 '05 #1
2 2107
"Alex Nitulescu" <RE***********************@yahoo.com> wrote in message
news:u5**************@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
Nov 19 '05 #2
Thanks, it works fine now !

"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"Alex Nitulescu" <RE***********************@yahoo.com> wrote in message
news:u5**************@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

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.