0

How do I only store the time part in date time object? I am doing this:

            DateTime.TryParseExact(DateTime.Now.ToString("HH:mm:ss"), "HH:mm:ss",
                              new CultureInfo("en-US"),
                              DateTimeStyles.None, out outTime);
            Datetime LogTime = outTime;

But it still add date to it. I only want like "13:01:03" instead of "2019-10-31 13:01:03.000".

Stackyboy
  • 55
  • 1
  • 7

1 Answers1

0

Time without a date is usually meaningless.

However, if you must store only the time, then TimeSpan would be appropriate. It offers some advantage over UInt64 by way of convenient methods of transforming milliseconds into other time units.

This will end up holding the milliseconds since "the beginning", where "the beginning" will have to be defined by you.

Sam Axe
  • 33,313
  • 9
  • 55
  • 89