Which function return the desktop long and short date formats?

  • Thread starter Thread starter ABC
  • Start date Start date
Hi ABC,
the System.Globalization.DateTimeFormatInfo class contains methods to help
you. For example the long date of the current culture can be found using:

System.Globalization.DateTimeFormatInfo.CurrentInfo.LongDatePattern
On my computer the string returned is: dddd, MMMM dd, yyyy

Also:
System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern
System.Globalization.DateTimeFormatInfo.CurrentInfo.FullDateTimePattern

Hope that helps
Mark R Dawson
http://www.markdawson.org
 
ABC said:
Hi, All

Which function return the desktop long and short date formats?

Thanks
for ShortDatePattern use format string "d".
for LongDatePattenr use format string "D".

e.g.
DateTime dateVar;

string shortDate = dateVar.ToString("d");
string longDate = dateVar.ToString("D");

For more format string look in the doku.
Search for: "Standard DateTime Format Strings" or "Custon DateTime Format
Strings"

Christof
 
Back
Top