In C#, DateTime.ToLongTimeString() returns the time of day with seconds, such as 14:30:45 in the invariant culture. The date part is not included.
The layout comes from the current culture. The method is the same as ToString("T").
This is an instance member of System.DateTime. You call it on a DateTime value, such as dt.ToLongTimeString(...). DateTime is a struct, so every value is copied and never changed in place.
Syntax
Call it on a DateTime. It takes no arguments.
C#
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
DateTime dt = new DateTime(2026, 11, 18, 14, 30, 45);
string s = dt.ToLongTimeString(); // "14:30:45"
Call
What it does
dt.ToLongTimeString()
Hours, minutes, and seconds in the current culture.
dt.ToString("T")
The same result with a format letter.
dt.ToString("HH:mm:ss", culture)
A custom pattern that is the same in every culture.
Milliseconds are not shown. Use the fff pattern (for example HH:mm:ss.fff) when you need them.
Library declarations
C#
public string ToLongTimeString();
Parameters
Parameter
Description
None
ToLongTimeString() takes no parameters.
Return Value
Return Value
Description
string
The time in the long time pattern of the current culture. The date and fractions of a second are not included.
C# Examples
Example 1 — Time with Seconds
Print a long time for an afternoon and an early morning value.
C#
using System;
using System.Globalization;
class Program {
static void Main() {
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
DateTime a = new DateTime(2026, 11, 18, 14, 30, 45);
DateTime b = new DateTime(2026, 11, 18, 0, 5, 9);
Console.WriteLine(a.ToLongTimeString());
Console.WriteLine(b.ToLongTimeString());
}
}
Output
14:30:45
00:05:09
How It Works
Fixed culture. The invariant culture uses a 24-hour clock with seconds.
Three parts. The result has hours, minutes, and seconds separated by colons.
Small numbers padded. The second value prints 00:05:09 with leading zeros.
Date ignored. Both values are on November 18, but the date is not in the text.
Example 2 — Milliseconds Are Dropped
Show that 999 milliseconds are cut off and that the date does not matter.
C#
using System;
using System.Globalization;
class Program {
static void Main() {
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
DateTime a = new DateTime(2026, 11, 18, 14, 30, 45, 999);
DateTime b = new DateTime(2027, 1, 1, 14, 30, 45);
Console.WriteLine(a.ToLongTimeString());
Console.WriteLine(a.ToLongTimeString() == b.ToLongTimeString());
}
}
Output
14:30:45
True
How It Works
999 ms. The first value is almost one full second later than 14:30:45.
Cut, not rounded. The text still shows second 45.
Different dates. The second value is in 2027, but has the same clock time.
Equal text. Only the clock matters, so the comparison prints True.
Example 3 — Match ToString Formats
Compare ToLongTimeString with the T format and with a custom pattern.
C#
using System;
using System.Globalization;
class Program {
static void Main() {
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
DateTime dt = new DateTime(2026, 11, 18, 14, 30, 45);
Console.WriteLine(dt.ToLongTimeString() == dt.ToString("T"));
Console.WriteLine(dt.ToLongTimeString() == dt.ToString("HH:mm:ss", CultureInfo.InvariantCulture));
}
}
Output
True
True
How It Works
Same method, new name.ToString("T") uses the long time pattern too.
First check. The two strings are equal, so the result is True.
Custom pattern. For the invariant culture, the long time pattern is exactly HH:mm:ss.
Second check. This is also True, but only because the culture is invariant.
Frequently Asked Questions
Hours, minutes, and seconds, for example 14:30:45 in the invariant culture.
Yes. Both use the long time pattern of the current culture.
No. Use a custom pattern such as HH:mm:ss.fff.
Some cultures use a 12-hour clock. The current culture decides.
Use ToString("HH:mm:ss", CultureInfo.InvariantCulture) or the "o" format so the text is the same everywhere.