views:

513

answers:

3

Hello,

We have a web application that gets its data from a certain database. The product writing to that database has been localized to RUSSIAN, thus its data, in particular the dates had been localized too.

We encountered a problem where our DATES would not show on our application. We traced the problem to an invalid Date.parse() javascript call.

Example:

<html>
<body>

<script type="text/javascript">
var value = Date.parse("01/31/2009 08:00:00 AM");
document.write(value);
</script>

</body>

Would return 1260576000000.

However,

<html>
<body>

<script type="text/javascript">
var value = Date.parse("31.01.2009 08:00:00 AM");
document.write(value);
</script>

</body>

Would return NaN.

Is there a way to parse localized dates in Javascript?

Thanks!

+1  A: 

The built-in function does not support i18n. Use a toolkit, auch as dojo, to parse and output dates.

Lucero
+1  A: 

It looks like the sort of situation where I would find a friendly developer who knows Regex. Regex should be able to turn one type of date format to another before you parse the string.

edeverett
You're right... We can massage the date to fit the parse criteria. However, that would only work if we're only working with Russian dates. But that's not the case, we are localizing in 5 different languages.
Ian
A: 

I have the problem with german lanuage..

Converting of 20 Okt 2009 failed but Jul for example works.. How i can set the localisation?

As said by Lucero, you would need a toolkit to handle localized dates. Javascript only would not suffice.
Ian