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.getD ate();
var mm=dataNow.getM onth()+1;
var yy=dataNow.getY ear();
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. 6 9342
Franz wrote: var yy=dataNow.getY ear();
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
On 08/06/2005 09:50, Franz wrote:
[snip] var yy=dataNow.getY ear();
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.
Michael Winter said: On 08/06/2005 09:50, Franz wrote:
[snip]
var yy=dataNow.getY ear();
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 implementati on 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".
JRS: In article <42********@x-privat.org>, dated Wed, 8 Jun 2005
10:50:57, seen in news:comp.lang. javascript, Franz
<an*******@anon ymous.com> posted : I have a problem with a date in javascript on firefox Browser. var yy=dataNow.getY ear();
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.ge tTime() / 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.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
"Michael Winter" <m.******@bluey onder.co.invali d> wrote in message
news:F3******** **********@text .news.blueyonde r.co.uk... On 08/06/2005 09:50, Franz wrote:
[snip]
var yy=dataNow.getY ear();
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*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq
JRS: In article <%Y************ *@news2.mts.net >, dated Fri, 10 Jun 2005
17:19:55, seen in news:comp.lang. javascript, Grant Wagner
<gw*****@agrico reunited.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,2 001 or 97,98,99,100,10 1".
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.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 locked in US.
As we migrated certain apps over to the new machine. we found out
something... someone coded a Now.ToString in a database query... and the SQL
Box is running MM/dd/yyyy! Chaos follows!!!
I tried setting the Administrator account's...
|
by: Kiran |
last post by:
Hi,
Is it possible to display date in different languages depending upon the
culture.
Thanks
Kiran
|
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
|
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 problem in Date format.
Scenario is :
If my application is running in the following setup, i.e The SQL server2000 is installed with DDMMY format and system setting also DDMMYY.
Now when the user enters the date like 19-04-2007 in the UI,it is...
|
by: sumaiya |
last post by:
how can i display date subtraction
| |
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 dd/mm/yy format.
Please help
Regards
Manoj
|
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.
|
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 field has date in "mm/dd/yyyy" format (for ex: 09/03/2008), the textbox displays it as 9/3/2008.
Can anyone suggest how to display date in "mm/dd/yyyy" format in a bounded textbox.
Thanks!
|
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 don't know why!
I tried to change default date in windows but after that I have also problem with date!
Please help me!
If you have any questions, don't hesitate to contact me!
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |