suresh64633 Posted September 16, 2009 Share Posted September 16, 2009 Hi I have a table in which time is store as "1.00 PM" in varchar datatype. Now i want to sort records with this fields. As it is varchar it does not work properly. I need any function [AS strtotime() in php] by which i can convert this time to 24 hours format so i can sort it easily. Thanks!! Link to comment https://forums.phpfreaks.com/topic/174439-solved-change-format-from-12-hrs-to-24-hrs/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 16, 2009 Share Posted September 16, 2009 http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_str-to-date Link to comment https://forums.phpfreaks.com/topic/174439-solved-change-format-from-12-hrs-to-24-hrs/#findComment-919433 Share on other sites More sharing options...
suresh64633 Posted September 16, 2009 Author Share Posted September 16, 2009 i try to use like this but not working SELECT STR_TO_DATE( '09:30:17 PM', '%h:%i:%s' ) ; result is "09:30:17" it should be 21:30:17 Thanks Link to comment https://forums.phpfreaks.com/topic/174439-solved-change-format-from-12-hrs-to-24-hrs/#findComment-919444 Share on other sites More sharing options...
artacus Posted September 16, 2009 Share Posted September 16, 2009 SELECT STR_TO_DATE( '09:30:17 PM', '%h:%i:%s %p' ) ; Missing the AM/PM indicator. Link to comment https://forums.phpfreaks.com/topic/174439-solved-change-format-from-12-hrs-to-24-hrs/#findComment-919511 Share on other sites More sharing options...
suresh64633 Posted September 17, 2009 Author Share Posted September 17, 2009 Thanks artacus Link to comment https://forums.phpfreaks.com/topic/174439-solved-change-format-from-12-hrs-to-24-hrs/#findComment-919884 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.