How to extract and display the seconds from DateTime in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime now = DateTime.Now;

            string sec = now.ToString("s ");
            Console.WriteLine($"{sec}");
        }
    }
}


/*
run:
 
36

*/

 



answered Aug 14, 2018 by avibootz

Related questions

1 answer 225 views
2 answers 333 views
2 answers 342 views
1 answer 272 views
3 answers 405 views
1 answer 242 views
1 answer 339 views
...