HighDots Forums  

Date in regional format in different regions

Javascript JavaScript language (comp.lang.javascript)


Discuss Date in regional format in different regions in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Andrew Poulos
 
Posts: n/a

Default Date in regional format in different regions - 05-02-2005 , 05:00 AM






I'm updating a db in which I have a column of Date/Time data type. The
regional settings here for short date are:
day / month / full year
eg. 28/4/2005

It's easy enough for me to build a string with the appropriate date but
how do I handle different regional settings for short date, such as:
month / day / full year


Andrew Poulos

Reply With Quote
  #2  
Old   
Evertjan.
 
Posts: n/a

Default Re: Date in regional format in different regions - 05-02-2005 , 07:09 AM






Andrew Poulos wrote on 02 mei 2005 in comp.lang.javascript:

Quote:
I'm updating a db in which I have a column of Date/Time data type. The
regional settings here for short date are:
day / month / full year
eg. 28/4/2005

It's easy enough for me to build a string with the appropriate date but
how do I handle different regional settings for short date, such as:
month / day / full year

You don't have to handle those, as the client settings will do it for you.

Perhaps however your idea of "handling" differs from mine.

Please be more explicit about that.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)



Reply With Quote
  #3  
Old   
Andrew Poulos
 
Posts: n/a

Default Re: Date in regional format in different regions - 05-02-2005 , 08:03 AM



Evertjan. wrote:

Quote:
Andrew Poulos wrote on 02 mei 2005 in comp.lang.javascript:


I'm updating a db in which I have a column of Date/Time data type. The
regional settings here for short date are:
day / month / full year
eg. 28/4/2005

It's easy enough for me to build a string with the appropriate date but
how do I handle different regional settings for short date, such as:
month / day / full year



You don't have to handle those, as the client settings will do it for you.

Perhaps however your idea of "handling" differs from mine.

Please be more explicit about that.

The db with the current regional settings expects the date in this
format dd/mm/yyyy. The best I can do with js is this:
theDate.getDate() +"/"+ (theDate.getMonth()+1) +"/"+ theDate.getFullYear

but that means that I've 'fixed' the format. How can I know what the
regional settings for date are? (The db may be installed on a system
with a differing regional setting to what I'm building for.)

toLocaleDateString() gives an output like
Monday, 2 May 2005

should I parse/massage this i.e. strip the leading day name comma and
space; replace the other spaces with forward slashes; and replace any
alphabetic characters with the current month number?


Andrew Poulos







Reply With Quote
  #4  
Old   
Evertjan.
 
Posts: n/a

Default Re: Date in regional format in different regions - 05-02-2005 , 08:15 AM



Andrew Poulos wrote on 02 mei 2005 in comp.lang.javascript:
Quote:
The db with the current regional settings expects the date in this
format dd/mm/yyyy. The best I can do with js is this:
theDate.getDate() +"/"+ (theDate.getMonth()+1) +"/"+ theDate.getFullYear
You don't specify the db engine you use,
but common advice is to use yyyy/mm/dd
in SQL string litterals of the type date.

theDate.getFullYear+"/"+(theDate.getMonth()+1)+"/"+theDate.getDate()

I suppose we are now talking serverside ASP jscript?
What engine?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)



Reply With Quote
  #5  
Old   
Andrew Poulos
 
Posts: n/a

Default Re: Date in regional format in different regions - 05-02-2005 , 10:17 AM



Evertjan. wrote:
Quote:
Andrew Poulos wrote on 02 mei 2005 in comp.lang.javascript:

The db with the current regional settings expects the date in this
format dd/mm/yyyy. The best I can do with js is this:
theDate.getDate() +"/"+ (theDate.getMonth()+1) +"/"+ theDate.getFullYear


You don't specify the db engine you use,
but common advice is to use yyyy/mm/dd
in SQL string litterals of the type date.


Ah, I get it (finally) I need to specifically nominate the date format
instead of simply choosing a preset.

Thanks
Andrew Poulos


Reply With Quote
  #6  
Old   
Evertjan.
 
Posts: n/a

Default Re: Date in regional format in different regions - 05-02-2005 , 11:56 AM



Andrew Poulos wrote on 02 mei 2005 in comp.lang.javascript:

Quote:
Evertjan. wrote:
Andrew Poulos wrote on 02 mei 2005 in comp.lang.javascript:

The db with the current regional settings expects the date in this
format dd/mm/yyyy. The best I can do with js is this:
theDate.getDate() +"/"+ (theDate.getMonth()+1) +"/"+ theDate.getFullYear


You don't specify the db engine you use,
but common advice is to use yyyy/mm/dd
in SQL string litterals of the type date.


Ah, I get it (finally) I need to specifically nominate the date format
instead of simply choosing a preset.
I think you don't.

If you format the date to be used in an sql string as yyyy/mm/dd it will
always be understood correctly by most database engines.

If you want more help please answer the quetions in my last posting:

1
Quote:
I suppose we are now talking serverside ASP jscript?
2
Quote:
What database engine are you using?



--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)



Reply With Quote
  #7  
Old   
Dr John Stockton
 
Posts: n/a

Default Re: Date in regional format in different regions - 05-02-2005 , 05:31 PM



JRS: In article <4275ec23$0$12809$5a62ac22@per-qv1-newsreader-
01.iinet.net.au>, dated Mon, 2 May 2005 19:00:18, seen in
news:comp.lang.javascript, Andrew Poulos <ap_prog (AT) hotmail (DOT) com> posted :
Quote:
I'm updating a db in which I have a column of Date/Time data type. The
regional settings here for short date are:
day / month / full year
eg. 28/4/2005

It's easy enough for me to build a string with the appropriate date but
how do I handle different regional settings for short date, such as:
month / day / full year
In addition to what has been said : if you can arrange to read a known
date from the database, a date with Y M and D all different, then a
little logic will determine what format it outputs. The database can
probably read that format.

But use YYYY-MM-DD if you can, and as a second choice YYYY/MM/DD - wach
with fields padded to 4 2 2 with leading zeroes.




For those interested, with non-MSIE browsers : the core of the new part
of <URL:http://www.merlyn.demon.co.uk/js-boxes.htm> could do with a re-
check.

Depict, which used a form and a table around a textarea, is replaced by
a simpler Depikt, which uses CSS for the area surround.

The appearance on my system is perceptibly different, but still matches
the written description.

--
© 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.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.