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 258 views
2 answers 323 views
1 answer 216 views
216 views asked Jun 12, 2020 by avibootz
1 answer 277 views
1 answer 161 views
161 views asked Jun 27, 2022 by avibootz
1 answer 224 views
224 views asked Jun 12, 2020 by avibootz
...