|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Using american dates by defaultHi guys,
I'm developing a web app on a UK computer. When I put a date into a textbox, its in the format DD/MM/YY. The DateTime object takes that in and handles in perfectly. Now, I need to start using the american format MM/DD/YY. My question is, how do I get the DateTime object to recognise what I'm passing in as an American date? If the machine is installed on an american server, will it immediately expect the dates as american? Or do I need to do something else? Many thanks Simon thechaosengine wrote:
> I'm developing a web app on a UK computer. When I put a date into a textbox, You can tell DateTime.Parse which CultureInfo to use. If you don't> its in the format DD/MM/YY. The DateTime object takes that in and handles > in perfectly. > > Now, I need to start using the american format MM/DD/YY. > > My question is, how do I get the DateTime object to recognise what I'm passing > in as an American date? If the machine is installed on an american server, > will it immediately expect the dates as american? Or do I need to do something > else? specify anything, it uses the CultureInfo for the current thread. Jon > You can tell DateTime.Parse which CultureInfo to use. If you don't Sorry to hijack slightly, however how do you instruct SQL server to save > specify anything, it uses the CultureInfo for the current thread. > > Jon dates in UK format? The DateTime class again maintains my uk date however SQL writes it out in america format, any clues ideas? Thanks, Taz re:
> The DateTime class again maintains my uk date however SQL writes it out in america format, any If you want dates to be displayed using uk format, set "culture" and "uiCulture",> clues ideas? in the globalization section of web.config, to "en-GB". Anything you display in ASP.NET pages from that point on, will be displayed using UK date and currency formats. <globalization culture="en-GB" uiCulture="en-GB" /> Juan T. Llibre, asp.net MVP aspnetfaq.com : http://www.aspnetfaq.com/ asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ =================================== Show quoteHide quote "Tarun Mistry" <ukbrainsto***@gmail.com> wrote in message news:%23hLRIqlLGHA.3896@TK2MSFTNGP15.phx.gbl... >> You can tell DateTime.Parse which CultureInfo to use. If you don't >> specify anything, it uses the CultureInfo for the current thread. >> >> Jon > Sorry to hijack slightly, however how do you instruct SQL server to save dates in UK format? > > The DateTime class again maintains my uk date however SQL writes it out in america format, any > clues ideas? > > Thanks, > Taz > Hi Juan
Your code has been proved a gr8 help to me. Thnx a lot. Ruju Show quoteHide quote "Juan T. Llibre" wrote: > re: > > The DateTime class again maintains my uk date however SQL writes it out in america format, any > > clues ideas? > > If you want dates to be displayed using uk format, set "culture" and "uiCulture", > in the globalization section of web.config, to "en-GB". > > Anything you display in ASP.NET pages from that point on, > will be displayed using UK date and currency formats. > > <globalization culture="en-GB" uiCulture="en-GB" /> > > > > Juan T. Llibre, asp.net MVP > aspnetfaq.com : http://www.aspnetfaq.com/ > asp.net faq : http://asp.net.do/faq/ > foros de asp.net, en español : http://asp.net.do/foros/ > =================================== > "Tarun Mistry" <ukbrainsto***@gmail.com> wrote in message > news:%23hLRIqlLGHA.3896@TK2MSFTNGP15.phx.gbl... > >> You can tell DateTime.Parse which CultureInfo to use. If you don't > >> specify anything, it uses the CultureInfo for the current thread. > >> > >> Jon > > > Sorry to hijack slightly, however how do you instruct SQL server to save dates in UK format? > > > > The DateTime class again maintains my uk date however SQL writes it out in america format, any > > clues ideas? > > > > Thanks, > > Taz > > > > > "Tarun Mistry" <ukbrainsto***@gmail.com> wrote in message SQL Server doesn't store dates in any particular format as such - they are news:%23hLRIqlLGHA.3896@TK2MSFTNGP15.phx.gbl... > Sorry to hijack slightly, however how do you instruct SQL server to save > dates in UK format? simply numbers. > The DateTime class again maintains my uk date however SQL writes it out in Open up Books Online and do a search for CAST AND CONVERT. That will show > america format, any clues ideas? you how to format dates using various national conventions etc. However, generally speaking, it would be better to do this in your presentation layer. Hello Jon Skeet [C# MVP],
OK, thats cool. Now, just one last thing. Would I be right in thinking that if the code is running on an american server, it will default to the american way of doing dates? I'm pretty sure it should... Thanks Simon thechaosengine wrote:
> OK, thats cool. *Probably*. If it's an ASP.NET app, you may find it takes the UI> > Now, just one last thing. Would I be right in thinking that if the code is > running on an american server, it will default to the american way of doing > dates? > > I'm pretty sure it should... culture (set on the thread from what the browser provides) rather than the "normal" culture. I can't remember off the top of my head. Definitely try it on a US-based server with browser settings for US and UK. Jon
Other interesting topics
Duplicate custom controls
List files in a directory, modify name. How to Store web pages to local disk using httpwebrequest asp.net control to run in web page like just COM Wierd Warnings: mailSettings modification results in many web.config messages browser compat issue PostBackURL to new window 'Timeout period elapsed prior to obtaining a connection from the pool.' - Please help. Why use disconnected datasets? Occurence of Char! |
|||||||||||||||||||||||