How to extract the time part from a DateTime datatype in C#
(Thursday, August 19, 2004)
How to extract only the time from a DateTime datatype in C#
This example will show how to extract only the time from a DateTime datatype containing a date and a time in C#.
//C# string strDateTime = "01/02/2002 11:30:12 AM";
// Displays 11:30 AM Console.WriteLine(DateTime.Parse(strDateTime).ToShortTimeString()); // Displays 11:30:12 AM Console.WriteLine(DateTime.Parse(strDateTime).ToLongTimeString());
Posted by Xander Zelders

|
0 Comments:
Post a Comment
<< Home