How can we convert the time in AM/PM to 24-hrs format. For eg. (1:30 PM) should be converted to (13:30).
The DATE_FORMAT() will do this for you. %r and %T are 12 hour and 24 hour time formats respectively.
In SQL Server 2012, we can use Format function to have suitable date time format. Use capital letter 'HH:mm:ss' for 24 hour date time format.
But if you want to store AM/PM you need to use varchar datatype. I suggest you to use ->format(); while you get the timestamp data. This will convert the date time format as your wish. For now, as you want to display AM/PM after time, use it like: ->format('g:i A'); This will show time like 10:28 PM .
MySQL retrieves and displays DATETIME values in ' YYYY-MM-DD hh:mm:ss ' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59' . The TIMESTAMP data type is used for values that contain both date and time parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.
Dates / Times are stored in mysql the same way regardless of how they are formatted.
I believe what you want to do is retrieve the date in a specified format.
The DATE_FORMAT() will do this for you.
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format
%r and %T are 12 hour and 24 hour time formats respectively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With