Answers for "c sharp convert string time into 24 hours time"

C#
0

c sharp convert string time into 24 hours time

DateTime dateTime = DateTime.Now;
string strMinFormat = dateTime.ToString("hh:mm:ss tt");//12 hours format
string strMaxFormat = dateTime.ToString("HH:mm:ss tt");//24 hours format
Posted by: Guest on August-20-2021
0

c sharp convert string time into 24 hours time

using System;
namespace Demo {
   public class Program {
      public static void Main(string[] args) {
         DateTime d = DateTime.Parse("05:00 PM");
         Console.WriteLine(d.ToString("HH:mm"));
      }
   }
}
Posted by: Guest on August-20-2021
0

c sharp convert string time into 24 hours time

using System;

class Solution
{
    static string timeConversion(string s)
    {
        return DateTime.Parse(s).ToString("HH:mm");
    }

    static void Main(string[] args)
    {
        Console.WriteLine(timeConversion("01:00 PM"));
        Console.Read();
    }
}
Posted by: Guest on August-20-2021

Code answers related to "c sharp convert string time into 24 hours time"

C# Answers by Framework

Browse Popular Code Answers by Language