This post will discuss how to get the current time without a date in C#.

The DateTime.Now property returns a DateTime object whose value is the current date and time. To get the time component of DateTime.Now, use any of the following methods:

1. Using DateTime.ToString() method

The DateTime.ToString() method can be used to get the string representation of the current DateTime object in a specified format.

Download  Run Code

 
Alternatively, we can use the short time t format specifier, which displays the value of the current DateTime object value using a short time pattern.

Download  Run Code

 
We can also use a long time T format specifier that displays the value of the current DateTime object value using a long time pattern.

Download  Run Code

2. Using DateTime.ToShortTimeString() method

The DateTime.ToShortTimeString() method can be used to convert the value of the current DateTime object to its equivalent short time string representation.

Download  Run Code

3. Using DateTime.ToLongTimeString() method

The DateTime.ToLongTimeString() method can be used to convert the value of the current DateTime object to its equivalent long time string representation.

Download  Run Code

4. Using DateTime.GetDateTimeFormats() method

The DateTime.GetDateTimeFormats() method returns an array of all the string representations of the current DateTime object supported by the specified format specifier. The idea is to pass the T format specifier to the method and print the first value in the returned array.

Download  Run Code

That’s all about getting the current time without date in C#.