
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# program to convert time from 12 hour to 24 hour format
Firstly, set the 12 hr format date.
DateTime d = DateTime.Parse("05:00 PM");
Now let us convert it into 24-hr format.
d.ToString("HH:mm"));
The following is the code to covert time from 12 hour to 24 hour format −
Example
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")); } } }
Output
17:00
Advertisements