using System;
class MainClass {
public static void Main() {
DateTime dt = DateTime.Now; // obtain current time
Console.WriteLine("d format: {0:d}", dt);
Console.WriteLine("D format: {0:D}", dt);
Console.WriteLine("t format: {0:t}", dt);
Console.WriteLine("T format: {0:T}", dt);
Console.WriteLine("f format: {0:f}", dt);
Console.WriteLine("F format: {0:F}", dt);
Console.WriteLine("g format: {0:g}", dt);
Console.WriteLine("G format: {0:G}", dt);
Console.WriteLine("m format: {0:m}", dt);
Console.WriteLine("M format: {0:M}", dt);
Console.WriteLine("r format: {0:r}", dt);
Console.WriteLine("R format: {0:R}", dt);
Console.WriteLine("s format: {0:s}", dt);
Console.WriteLine("u format: {0:u}", dt);
Console.WriteLine("U format: {0:U}", dt);
Console.WriteLine("y format: {0:y}", dt);
Console.WriteLine("Y format: {0:Y}", dt);
}
}
Output d format: 25/03/2007
D format: March 25, 2007
t format: 1:53 PM
T format: 1:53:55 PM
f format: March 25, 2007 1:53 PM
F format: March 25, 2007 1:53:55 PM
g format: 25/03/2007 1:53 PM
G format: 25/03/2007 1:53:55 PM
m format: March 25
M format: March 25
r format: Sun, 25 Mar 2007 13:53:55 GMT
R format: Sun, 25 Mar 2007 13:53:55 GMT
s format: 2007-03-25T13:53:55
u format: 2007-03-25 13:53:55Z
U format: March 25, 2007 8:53:55 PM
y format: March, 2007
Y format: March, 2007
|