help you need to leave only time from the text (hour / min / sec) and output to the console example: 01/30/2014 10:32:44 36324 36324 36324 36324 2 it turns out:

while ((line = file.ReadLine()) != null) { DateTime mydatatime = DateTime.Parse(line.Substring(0, 19)); Console.WriteLine("{0}", mydatatime); counter++; } 

The result will be

BUT I only need time, but I have a date and time

  • Console.WriteLine ("{0}", mydatatime.ToLongTimeString ()) - Pavel

1 answer 1

Specify a specific format for output, for example

 Console.WriteLine(mydatatime.ToString("H:mm:ss")); 

Full help on date and time formatting: Strings of customizable date and time formats .

  • and when I open the file Ilya Vityuk
  • No, he didn’t roll it to the console, which is now Ilya Vityuk
  • @ Ilyavityuk Well, substitute DateTime.Now instead of your time from the file - mydatatime - PashaPash
  • I did everything so where you gave the link: - Ilya Vityuk
  • Console.WriteLine (mydatatime.ToString ("H: mm: ss")); - Ilya Vityuk February