以下示例将以指定格式更改当前时间 -
mysql> SELECT DATE_FORMAT(NOW(), 'The time is %h:%i:%s %p');
+-----------------------------------------------+
| DATE_FORMAT(NOW(), 'The time is %h:%i:%s %p') |
+-----------------------------------------------+
| The time is 06:02:28 AM |
+-----------------------------------------------+
1 row in set (0.00 sec)
登录后复制
以下示例将以指定格式更改给定时间 -
mysql> SELECT DATE_FORMAT('2017-10-29 06:03:25', 'The time is %h:%i:%s %p');
+---------------------------------------------------------------+
| DATE_FORMAT('2017-10-29 06:03:25', 'The time is %h:%i:%s %p') |
+---------------------------------------------------------------+
| The time is 06:03:25 AM |
+---------------------------------------------------------------+
1 row in set (0.00 sec)
登录后复制
以上就是在MySQL中,如何以用户指定的其他格式显示时间?的详细内容,更多请关注每日运维网(www.mryunwei.com)其它相关文章!