Re: Australian Date
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Australian Date

From: Evertjan. <exjxw.hannivoort@interxnl.net>
Date: Wed Nov 23 2005 - 10:53:21 CET

 wrote on 23 nov 2005 in comp.lang.javascript:

> Hi,
>
> I'm trying to work with the Australian date formats and javascript and
> it's causing me quite a headache. I have a date in a "dd/mm/yy" format.
> Whenever I try to retrieve that date from my javascript, it'd return
> some random date that doesn't make sense.
>
> For example,

Wrong example, this is not working like you describe:

> var time = new Object;
> time.Date = "24/11/05"; //Nov. 24, 2005
> alert(time.Date);
>
> Now I'd get something 12/11/2006 in my alert box.

<script type='text/jscript'>

  var time = new Date("24/11/05"); //Nov. 24, 2005
  document.write(time);

  // Tue Dec 11 00:00:00 UTC+0100 1906
  // +0100 being my set regional time zone

</script>

This code works correctly, as the machine interprets
24/11/05 as the 11th day of the 24th month of 1905

[Depending on your regional setting being dd/mm/yyyy]

===========================

Solution [regional settings independent]:

always use yyyy/mm/dd

var time = new Date("2005/11/24"); //Nov. 24, 2005

-- 
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Received on Sat Dec 3 04:28:56 2005