Reputation: 35
How can i get the Time only in the DateTime?
Example
01/27/12 04:00PM
i want only to display 04:00PM is there a way to get that? :)
Thanks in advance
Upvotes: 0
Views: 1770
Reputation: 1655
Try This Code :
DateTime thisDate1 = new DateTime(01/27/12 04:00PM);
Console.WriteLine("The current date and time: {0:H:mm:ss zzz}",
thisDate1);
For more help please visit this link Custom date formate
Upvotes: 0
Reputation: 1500165
Sure - just specify a custom format string which only includes the information you want. For example, "hh:mmtt" would do what you want here, I believe.
Upvotes: 4