About 544,000 results
Open links in new tab
  1. c# - Convert string to Time - Stack Overflow

    May 20, 2014 · string Time = "16:23:01"; DateTime date = DateTime.ParseExact(Time, "hh:mm:ss tt", System.Globalization.CultureInfo.CurrentCulture); lblClock.Text = date.ToString(); I want it …

  2. How to parse strings to DateTime in C# properly? - Stack Overflow

    Mar 21, 2011 · Put the value of a human-readable string into a .NET DateTime with code like this: DateTime.ParseExact("April 16, 2011 4:27 pm", "MMMM d, yyyy h:mm tt", null);

  3. DateTime.Parse Method (System) | Microsoft Learn

    To prevent the difficulties in parsing data and time strings that are associated with changes in cultural data, you can parse date and time strings by using the invariant culture, or you can call …

  4. c# - Converting a String to DateTime - Stack Overflow

    May 28, 2009 · ParseExact will allow you to specify the exact format of your date string to use for parsing. It is good to use this if your string is always in the same format. This way, you can …

  5. Custom date and time format strings - .NET | Microsoft Learn

    Dec 3, 2022 · In parsing operations, custom date and time format strings can be used with the DateTime.ParseExact, DateTime.TryParseExact, DateTimeOffset.ParseExact, and …

  6. Convert strings to DateTime - .NET | Microsoft Learn

    Oct 4, 2022 · The ParseExact and TryParseExact methods convert a string representation that conforms to the pattern specified by a date and time format string. For more information, see …

  7. C# - Parsing a DateTime from a string - makolyte

    May 13, 2021 · You can convert a string to a DateTime (parse) with one of these methods: DateTime.Parse() (or TryParse). Use this to parse a variety of standard formats (culture …

  8. C# DateTime ParseExact - C# Tutorial

    In this example, we use the ParseExact() method to convert the date string "05/07/2023" to a DateTime with the format M/d/yyyy. The ParseExact() accepts three arguments: s is the input …

  9. c# - How to Convert string "07:35" (HH:MM) to TimeSpan - Stack Overflow

    Jun 23, 2014 · TimeSpan uses the standard or custom time span format strings. "07:35" can be parsed with the custom @"hh\:mm" (or "hh\\:mm" ) format in most cultures, including the …

  10. Mastering Time Formatting in C# - Best Practices and Examples

    Aug 7, 2024 · Whether you need to display time in a specific format, parse time from a string, or calculate time differences, understanding how to format time in C# is essential. In this blog …

  11. Some results have been removed