473,466 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

problem display date in firefox

Hy all,

I have a problem with a date in javascript on firefox Browser.
I use this javascript method:
var dataNow=new Date();
var dd=dataNow.getDate();
var mm=dataNow.getMonth()+1;
var yy=dataNow.getYear();
Firefox does not display the date correctly.
Instead of "2005" for the year, it displays "105", in IE Explorer, it looks
fine.
How can i solve that??

Thanks in advance.

Franz.
Jul 23 '05 #1
6 9325
Franz wrote:
var yy=dataNow.getYear();
Firefox does not display the date correctly.
Instead of "2005" for the year, it displays "105", in IE Explorer, it looks
fine.


use
getFullYear()

Daniel
Jul 23 '05 #2
On 08/06/2005 09:50, Franz wrote:

[snip]
var yy=dataNow.getYear();

Firefox does not display the date correctly.
Instead of "2005" for the year, it displays "105", in IE Explorer, it looks
fine.


Officially, there is no Date.prototype.getYear method, so an
implementation can do what it likes. However, the recommended behaviour
is the one displayed by Firefox: return the current year minus 1900.

The Date.prototype.getFullYear method is preferred as it has consistent
behaviour.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3
Lee
Michael Winter said:

On 08/06/2005 09:50, Franz wrote:

[snip]
var yy=dataNow.getYear();

Firefox does not display the date correctly.
Instead of "2005" for the year, it displays "105", in IE Explorer, it looks
fine.


Officially, there is no Date.prototype.getYear method, so an
implementation can do what it likes. However, the recommended behaviour
is the one displayed by Firefox: return the current year minus 1900.


Yesterday I saw an internal report that was timestamped "1050607".

Jul 23 '05 #4
JRS: In article <42********@x-privat.org>, dated Wed, 8 Jun 2005
10:50:57, seen in news:comp.lang.javascript, Franz
<an*******@anonymous.com> posted :
I have a problem with a date in javascript on firefox Browser.
var yy=dataNow.getYear();

Firefox does not display the date correctly.
Instead of "2005" for the year, it displays "105", in IE Explorer, it looks
fine. How can i solve that??


By reading the newsgroup FAQ; see below.

If you should need to support very very old browsers, you can use
instead of getFullYear

function getFY(D) { var YE
YE = Math.round(D.getTime() / 31556952000) + 1970
return YE + (D.getYear()-YE)%100 }

from my page js-date0.htm. The estimate YE is adjusted so that its last
two digits agree with getYear(). Of the numbers, only 100 needs to be
exact.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #5
"Michael Winter" <m.******@blueyonder.co.invalid> wrote in message
news:F3******************@text.news.blueyonder.co. uk...
On 08/06/2005 09:50, Franz wrote:

[snip]
var yy=dataNow.getYear();

Firefox does not display the date correctly.
Instead of "2005" for the year, it displays "105", in IE Explorer, it
looks
fine.


Officially, there is no Date.prototype.getYear method, so an
implementation can do what it likes. However, the recommended
behaviour is the one displayed by Firefox: return the current year
minus 1900.

The Date.prototype.getFullYear method is preferred as it has
consistent behaviour.


If your script might run in an environment where
Date.prototype.getFullYear is not available (since it was not introduced
until JavaScript 1.3 and JScript 3), you might be better off making sure
you a Date.prototype.getFullYear available:

if ('function' != typeof Date.prototype.getFullYear)
{
Date.prototype.getFullYear = function()
{
return (this.getYear() % 1900) + 1900;
}
}

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #6
JRS: In article <%Y*************@news2.mts.net>, dated Fri, 10 Jun 2005
17:19:55, seen in news:comp.lang.javascript, Grant Wagner
<gw*****@agricoreunited.com> posted :
If your script might run in an environment where
Date.prototype.getFullYear is not available (since it was not introduced
until JavaScript 1.3 and JScript 3), you might be better off making sure
you a Date.prototype.getFullYear available:
Agreed so far.
if ('function' != typeof Date.prototype.getFullYear)
{
Date.prototype.getFullYear = function()
{
return (this.getYear() % 1900) + 1900;
}
}


But only if the function always gives the correct result.

I have read, possibly here, that :-
"Method getYear can return any one of these three sequences for years :
97,98,99,00,01 or 97,98,99,2000,2001 or 97,98,99,100,101".

For 2001, those are not all equal modulo 1900; hence, that method cannot
always be right. I don't know which browser(s) give/gave 00,01.

That's why, after some thought, I produced function getFY() as
previously given in this thread and in my page js-date0.htm.

However, if the date is known to be current,
return 2000 + this.getYear()%100
will do for a while, and later on
return 2050 + (this.getYear()+50)%100
etc.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 23 '05 #7

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

Similar topics

3
by: Marauderz | last post by:
Hello guys, got a little question regarding the regional language settings . Anyway I got a Windows 2003 Server machine that was installed with the date format "dd/MM/yyyy" and location still...
2
by: Kiran | last post by:
Hi, Is it possible to display date in different languages depending upon the culture. Thanks Kiran
1
by: Agnes | last post by:
I give up the 'dd-mm-yyyy' bindign question. However, how can i make the text box display date without time ??? Thank
0
by: RadhakrishnanR | last post by:
HI ALL, My .NET application devloped in C# used mainly class file (OOAD) and user controls etc and it is desktop application not web based application. Database is SQL server 2000. Now I have...
2
sumaiya
by: sumaiya | last post by:
how can i display date subtraction
5
manoj9849967222
by: manoj9849967222 | last post by:
Hi All I have a problem with date format. I have designed a table with one of the field as Date. when i enter the date it is comming in mm/dd/yyyy format. Is there a way to change the format to...
1
by: jackiefm | last post by:
I need to display date ranges for missing data in a query in the following manner: 1/1/08-1/15/08, 126/08, 1/28/08-2/5/08, etc. as opposed to 1/1/08 1/2/08 1/3/08 etc.
1
by: JFKJr | last post by:
Hello everyone, this one might be simple but driving me crazy! Your help will be greatly appreciated. Basically, I created a textbox bound to "Date" field in an Access VBA form. But when the...
3
by: Jozo | last post by:
Dear All, This is my first time on this site and I am very happy! I have problem regarding to date (new or old ms access document) My problem is that access changes date after 09/11 to 11/09 i...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.