change date time format 
Author Message
 change date time format

hi all,
is there a way to get the system date as a specific format?
I need it as "MM/DD/YYYY"
when I change the format of my computer manually, will return the current
settings date format for System.DateTime.Today.

without formatting with strings is there a way to change it directly...

any help appreciated...

CMA



Fri, 01 Apr 2005 14:03:38 GMT  
 change date time format

Quote:

> hi all,
> is there a way to get the system date as a specific format?
> I need it as "MM/DD/YYYY"
> when I change the format of my computer manually, will return the current
> settings date format for System.DateTime.Today.

> without formatting with strings is there a way to change it directly...

If you look up "custom date and time format strings" in the Visual
Studio help index, you'll find a good example.

--

http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too



Fri, 01 Apr 2005 15:45:53 GMT  
 change date time format
Try this:

using System.Threading;
using System.Globalization;

string dat, dat1;
dat = System.DateTime.Today.ToString();
//displays 02-10-14 00:00:00
Thread.CurrentThread.CurrentCulture = new CultureInfo("pl-PL");
CultureInfo ci = Thread.CurrentThread.CurrentCulture;
ci.DateTimeFormat.ShortDatePattern = "MM/dd/yyyy";
//set new pattern
dat1 = System.DateTime.Today.ToString();
//displays 10-14-2002 00:00:00

Hope this helps
Piotr



Fri, 01 Apr 2005 16:12:46 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Change date field type from long to Date/Time

2. C time/date to Visual Basic time/date

3. Date Time Picker - Date AND Time

4. Formatted compile date and time?

5. Formatted __DATE__ and __TIME__ strings?

6. Date / Time Formatting Help

7. Formatted compile date and time?

8. Formatted __DATE__ and __TIME__ strings?

9. Date-Time Format (YYMMDDHHMMSS)

10. Format date and time

11. HELP!! Date time format

12. ORACLE ODBC date time format

 

 
Powered by phpBB® Forum Software