About 58,200,000 results
Open links in new tab
  1. How to use DateOnly and TimeOnly - .NET | Microsoft Learn

    Dec 5, 2024 · var theTime = new TimeOnly(11, 25, 46); // 11:25 AM and 46 seconds var theDate = new DateOnly(2015, 10, 21); // October 21, 2015 var theDateTime = …

  2. c# - Getting Date or Time only from a DateTime Object - Stack Overflow

    Nov 4, 2010 · You can use Instance.ToShortDateString() for the date, and Instance.ToShortTimeString() for the time to get date and time from the same instance.

  3. DateOnly And TimeOnly In C# - C# Corner

    TimeOnly in C#. The new TimeOnly struct can be used when we are just concerned with the time component. A good illustration of this is when an event is repeated every day at 9:00 AM. …

  4. DateOnly and TimeOnly in C# - Code Maze

    Apr 28, 2024 · DateOnly in C#. As the name suggests, we can use the new DateOnly struct when we want to represent only the date component. A good example might be some kind of …

  5. Removing Time Portion from DateTime in C#: Simple Methods

    Removing the time portion from a DateTime object in C# is straightforward using properties like Date, constructors, or formatting techniques. Whether you're working with date-only …

  6. How to get time from DateTime in C#? | 3 Easy Ways in .NET

    Jun 19, 2022 · The best way to get time from DateTime in C# is to: Access the TimeOfDay property of DateTime to get TimeSpan value for your DateTime. Access the Hours property of …

  7. C# TimeOnly - C# Tutorial

    To subtract hours from time, you can use a negative value in the AddHours() method. For example, the following uses the AddHours() method to subtract three hours from a time: var t …

  8. How to get only time from date-time C# - Stack Overflow

    Jun 22, 2009 · From a DateTime, you can use .TimeOfDay - but that gives you a TimeSpan representing the time into the day (10 hours). There is only DateTime type in C# and it consist …

  9. Get only time from Datetime in C#? - QA With Experts

    Jul 20, 2022 · To get only time, you can use datetime.ToString("h:mm tt"), so condering your example, you can have below code and output. dt.ToString("HH:mm"); // 15:52 PM // 24 hour …

  10. Working with DateOnly and TimeOnly in C# - C# Corner

    DateOnly is designed to work with date-only values, focusing exclusively on the year, month, and day components. It simplifies working with dates by removing the time and time zone …

  11. Some results have been removed
Refresh