Description |
Returns an array of all DateTime formatting patterns supported by .Net, or just those related to the given formatting PatternChar.
The PatternChar must be one of the following values :
d | Short Date, such as : 24/08/2004 |
D | Long date, such as 24 August 2004 |
t | Short time, such as 12:23 |
T | Long time, such as 12:23:45 |
f | Full datetime, such as 24 August 2004 12:23 |
F | Full datetime, such as 24 August 2004 12:23:45 |
g | General datetime, such as 24/08/2004 12:23 |
G | General datetime, such as 24/08/2004 12:23:45 |
M or m | Month, such as 24 August |
R or r | Culture independant, such as Tue 24 August 2004 12:23:45 GMT |
s | Sortable datetime, such as 2004-08-24T12:23:45 |
u | Universal sortable datetime |
Y or y | Year plus month, such as August 2004 |
|
|
Microsoft MSDN Links |
System.Globalization
System.Globalization.DateTimeFormatInfo
System.Globalization.DateTimeFormatInfo.GetAllDateTimePatterns
|
|
|
|
Listing all DateTime formatting strings |
program Project1;
{$APPTYPE CONSOLE}
uses
System.Globalization;
var
britCulture : System.Globalization.CultureInfo;
dateTimeFormat : System.Globalization.DateTimeFormatInfo;
patterns : Array of String;
i : Integer;
begin // Set up British culture
britCulture := CultureInfo.Create('en-GB');
// Get the date time format for this culture
dateTimeFormat := britCulture.DateTimeFormat;
// Get the date time format patterns into an array
patterns := dateTimeFormat.GetAllDateTimePatterns;
// And display all the date time formats
for i := 0 to Length(patterns)-1 do
Console.WriteLine(patterns[i]);
Console.ReadLine;
end.
|
dd/MM/yyyy
dd/MM/yy
d/M/yy
d.M.yy
yyyy-MM-dd
dd MMMM yyyy
d MMMM yyyy
dd MMMM yyyy HH:mm
dd MMMM yyyy H:mm
dd MMMM yyyy hh:mm tt
dd MMMM yyyy h:mm tt
d MMMM yyyy HH:mm
d MMMM yyyy H:mm
d MMMM yyyy hh:mm tt
d MMMM yyyy h:mm tt
dd MMMM yyyy HH:mm:ss
dd MMMM yyyy H:mm:ss
dd MMMM yyyy hh:mm:ss tt
dd MMMM yyyy h:mm:ss tt
d MMMM yyyy HH:mm:ss
d MMMM yyyy H:mm:ss
d MMMM yyyy hh:mm:ss tt
d MMMM yyyy h:mm:ss tt
dd/MM/yyyy HH:mm
dd/MM/yyyy H:mm
dd/MM/yyyy hh:mm tt
dd/MM/yyyy h:mm tt
dd/MM/yy HH:mm
dd/MM/yy H:mm
dd/MM/yy hh:mm tt
dd/MM/yy h:mm tt
d/M/yy HH:mm
d/M/yy H:mm
d/M/yy hh:mm tt
d/M/yy h:mm tt
d.M.yy HH:mm
d.M.yy H:mm
d.M.yy hh:mm tt
d.M.yy h:mm tt
yyyy-MM-dd HH:mm
yyyy-MM-dd H:mm
yyyy-MM-dd hh:mm tt
yyyy-MM-dd h:mm tt
dd/MM/yyyy HH:mm:ss
dd/MM/yyyy H:mm:ss
dd/MM/yyyy hh:mm:ss tt
dd/MM/yyyy h:mm:ss tt
dd/MM/yy HH:mm:ss
dd/MM/yy H:mm:ss
dd/MM/yy hh:mm:ss tt
dd/MM/yy h:mm:ss tt
d/M/yy HH:mm:ss
d/M/yy H:mm:ss
d/M/yy hh:mm:ss tt
d/M/yy h:mm:ss tt
d.M.yy HH:mm:ss
d.M.yy H:mm:ss
d.M.yy hh:mm:ss tt
d.M.yy h:mm:ss tt
yyyy-MM-dd HH:mm:ss
yyyy-MM-dd H:mm:ss
yyyy-MM-dd hh:mm:ss tt
yyyy-MM-dd h:mm:ss tt
dd MMMM
dd MMMM
ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
yyyy'-'MM'-'dd'T'HH':'mm':'ss
HH:mm
H:mm
hh:mm tt
h:mm tt
HH:mm:ss
H:mm:ss
hh:mm:ss tt
h:mm:ss tt
yyyy'-'MM'-'dd HH':'mm':'ss'Z'
dd MMMM yyyy HH:mm:ss
dd MMMM yyyy H:mm:ss
dd MMMM yyyy hh:mm:ss tt
dd MMMM yyyy h:mm:ss tt
d MMMM yyyy HH:mm:ss
d MMMM yyyy H:mm:ss
d MMMM yyyy hh:mm:ss tt
d MMMM yyyy h:mm:ss tt
MMMM yyyy
MMMM yyyy
|
|
Using a pattern |
program Project1;
{$APPTYPE CONSOLE}
uses
System.Globalization;
var
britCulture : System.Globalization.CultureInfo;
dateTimeFormat : System.Globalization.DateTimeFormatInfo;
patterns : Array of String;
i : Integer;
begin // Set up British culture
britCulture := CultureInfo.Create('en-GB');
// Get the date time format for this culture
dateTimeFormat := britCulture.DateTimeFormat;
// Get 'd' date time format patterns into an array
Console.WriteLine('''d'' formats :');
Console.WriteLine;
patterns := dateTimeFormat.GetAllDateTimePatterns('d');
// And display all the date time formats
for i := 0 to Length(patterns)-1 do
Console.WriteLine(patterns[i]);
// Get 'd' date time format patterns into an array
Console.WriteLine;
Console.WriteLine('''D'' formats :');
Console.WriteLine;
patterns := dateTimeFormat.GetAllDateTimePatterns('D');
// And display all the date time formats
for i := 0 to Length(patterns)-1 do
Console.WriteLine(patterns[i]);
Console.ReadLine;
end.
|
'd' formats :
dd/MM/yyyy
dd/MM/yy
d/M/yy
d.M.yy
yyyy-MM-dd
'D' formats :
dd MMMM yyyy
d MMMM yyyy
|
|