Friday, July 18, 2008

Conversion of datetime to 24 hour format

String militaryTimeFormat = "HH:mm";

String input = DateTime.Now.ToString(militaryTimeFormat);

DateTime time = DateTime.ParseExact(input, militaryTimeFormat, null);

string militaryTime = "06/12/2008 20:30";

IFormatProvider culture = new System.Globalization.CultureInfo("en-US", true);
DateTime militaryDate =DateTime.Parse(militaryTime, culture, System.Globalization.DateTimeStyles.NoCurrentDateDefault);


string g=DateTime.Now.ToString("dd/MM/yyyy HH:mm");
string h = DateTime.Now.ToString("HH:mm");

No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...