How to exclude seconds from DateTime to string 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:
 
53

*/

 



answered Aug 14, 2018 by avibootz

Related questions

1 answer 260 views
2 answers 325 views
1 answer 220 views
220 views asked Jun 12, 2020 by avibootz
1 answer 279 views
1 answer 164 views
164 views asked Jun 27, 2022 by avibootz
1 answer 225 views
225 views asked Jun 12, 2020 by avibootz
...