473,668 Members | 2,365 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can i get the date formatted according to the regional settings made at the operating system level

Hi All,

How can i get the date based on Regional settings .
how can i get the date format using C# .NET

" The date displayed in the date/time field should be formatted according to
the regional settings made at the operating system level. For example,
Canada uses a dd/mm/yyyy format while the US uses mm/dd/yyyy. The month and
day should be padded with zeros. In other words, use 01/01/2005 rather than
1/1/2005. The date will always appear as a range"
Please help me

Regards
venu.
Nov 16 '05 #1
3 5238
Karunakararao,

You can get an instance of the DateTimeFormatI nfo class from the static
CurrentInfo property on the DateTimeFormatI nfo class. Once you have that,
you can pass that to the ToString method to get a string representation of
the date in the local format.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Karunakara rao" <ka************ @i-vantage.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi All,

How can i get the date based on Regional settings .
how can i get the date format using C# .NET

" The date displayed in the date/time field should be formatted according to the regional settings made at the operating system level. For example,
Canada uses a dd/mm/yyyy format while the US uses mm/dd/yyyy. The month and day should be padded with zeros. In other words, use 01/01/2005 rather than 1/1/2005. The date will always appear as a range"
Please help me

Regards
venu.

Nov 16 '05 #2
Is that really necessary? If you use DateTime.ToShor tDateString() it will
automatically format the date in the format specified in the operating
system.

Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #3
Morten,

Necessary, no. The ToShortDateStri ng would work just fine in this
scenario.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Morten Wennevik" <Mo************ @hotmail.com> wrote in message
news:opr7scp1tt hntkfz@localhos t...
Is that really necessary? If you use DateTime.ToShor tDateString() it will
automatically format the date in the format specified in the operating
system.

Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2819
by: Richard Liddiment | last post by:
I am using FormatDateTime( mydbDate, vbShortDate) but it is NOT returning the date formatted according to my regional settings. My regional settings are "dd/MM/yyyy" but my date is returned as "d/m/yyyy". Where is it getting the format from so that I can correct it or is there a better way to format the date, the way I want it? I have tried the VB format function but get Type mismatch: 'Format'
7
3874
by: Colin Steadman | last post by:
I'm returning a date (5th Jan 2004) from Oracle using the following query: select TO_CHAR(invoice_date,'DD/MM/YYYY') from... This should return my date in the UK format, and it certainly appears to be doing just that in Toad. And it also looks correct in my form as it shows as: 05/01/2004
1
2362
by: OKI | last post by:
Hi. I had a VB program that was using an SQL Server 6.5 DB. Date format was dd/mm/yyyy. Now the DB was changed to an SQL Server 7 and the date format is yyyy/mm/dd. How can I do for changing date formats in the new DB to the old format? I´m searching for a database level solution, not server level.
1
4841
by: Laurence Neville | last post by:
This is regarding a change in the Short Date format under Hebrew Regional Settings, that has caused huge problems in our ASP web application. The change appears to have been introduced sometime before Windows 2000 Service Pack 4 and has remained through to Windows XP. I am looking for a solution that doesn't involve rewriting our application (much) and that allows all our users to keep using Hebrew Regional Settings. To summarize our...
0
984
by: Karunakararao | last post by:
Hi All, How can i get the date based on Regional settings . how can i get the date format using C# .NET " The date displayed in the date/time field should be formatted according to the regional settings made at the operating system level. For example, Canada uses a dd/mm/yyyy format while the US uses mm/dd/yyyy. The month and day should be padded with zeros. In other words, use 01/01/2005 rather than 1/1/2005. The date will...
5
3835
by: Ishaan | last post by:
Hi, Is there any way to pick the data format from operating system settings using C#? I am doing an ASP.Net Application. -- Software engineer Petroleum Development Oman
7
12626
by: Fred Flintstone | last post by:
I'm writing a VB.Net windows forms application. This line of code: Personal.EffectiveDate = GridRow2.Cells("New Value").Value.ToString.Trim Fails with this error: Cast from string "8/23/2005" to type 'Date' is not valid. The date being returned is in US English and my system is set for
7
6813
by: Richiep | last post by:
I am trying to get a UK format date of dd/mm/yyyy. Why does the following subroutine not return a valid date in a web form? The date returned is #12:00:00 AM# but the date I entered into the text box was 24/06/2006. The other solution I have tried is given by the following two lines that do not compile because a value of date type cannot be converted to datetime:
30
5692
by: fniles | last post by:
On my machine in the office I change the computer setting to English (UK) so the date format is dd/mm/yyyy instead of mm/dd/yyyy for US. This problem happens in either Access or SQL Server. In the database I have a table with Date/time column. The database is located on a machine that is set to dd/mm/yyyy also. When I enter date 7/1/08 (as in January 7, 2008), it stores it in the database as 1/7/08 instead of 7/1/08. Why is it like that...
0
8893
Oralloy
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...
0
8658
tracyyun
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...
0
7401
agi2029
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...
1
6209
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5681
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();...
0
4205
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...
0
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
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
2
2026
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.