20
1
using System;
2
3
public class DateTimeProgram
4
{
5
public static void Main()
6
{
7
DateTime CurrentDT= DateTime.Now;
8
//complete datetime
9
Console.WriteLine(CurrentDT);
10
//only date
11
Console.WriteLine(CurrentDT.ToString("d"));
12
// only date with formatted type
13
Console.WriteLine(CurrentDT.ToString("dd/MM/yyyy"));
14
15
//only time
16
Console.WriteLine(CurrentDT.ToString("hh:mm:ss tt"));
17
18
19
}
20
}
Cached Result