What is the method for converting MySQL time to a string?

In MySQL, you can convert time to a string using the DATE_FORMAT() function.

For example, converting the time field my_time to a string format of YYYY-MM-DD HH:MM:SS:

SELECT DATE_FORMAT(my_time, '%Y-%m-%d %H:%i:%s') AS my_time_str
FROM my_table;

The format template for the date is %Y-%m-%d %H:%i:%s, and it can be customized as needed. For specific formatting templates, refer to the MySQL official documentation.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds