- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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
- Related Articles
- C++ program to convert time from 12 hour to 24 hour format
- Python program to convert time from 12 hour to 24 hour format
- Convert time from 24 hour clock to 12 hour clock format in C++
- Converting 12 hour format time to 24 hour format in JavaScript
- How to convert 12-hour time scale to 24-hour time in R?
- Java Program to display time in 24-hour format
- Java Program to display Time in 12-hour format
- Program to convert hour minutes’ time to text format in Python
- How to convert string to 24-hour datetime format in MySQL?
- 24-hour time in Python
- Python Pandas - Format the Period object and display the Time with 24-Hour format
- Format hour in k (1-24) format in Java
- Format hour in kk (01-24) format in Java
- JavaScript program to convert 24 hours format to 12 hours
- MySQL convert timediff output to day, hour, minute, second format?

Advertisements