Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

converting date time to 24 hour format

Tags:

java

datetime

The time I get from the server is like Jul 27, 2011 8:35:29 AM.

I want to convert it to yyyy-MM-dd HH:mm:ss.

I also want the converted time to be in 24 hour format. Can any one give solution to this problem. The output I want to get is like 2011-07-27 08:35:29

like image 826
Sujiz Avatar asked Jul 27 '11 09:07

Sujiz


People also ask

How do I convert time to 24-hour format?

For example if the time in 12 hour clock is 11:00 PM, then the time in 24 hour clock is 11:00 + 12:00 = 23:00 hours.

How do I convert DateTime to 24-hour format in Python?

strptime() function to convert the string to a datetime object, and then using the string method strftime() to output the time in 24-hour format. The format code for 24-hour time is %H:%M whereas the format for 12-hour time is %I:%M with %p appended if the time contains AM/PM.


1 Answers

H vs h is difference between 24 hour vs 12 hour format.

like image 98
engineer Avatar answered Sep 28 '22 08:09

engineer