Home > Database > Mysql Tutorial > How to use date and time format characters together in MySQL DATE_FORMAT() function?

How to use date and time format characters together in MySQL DATE_FORMAT() function?

PHPz
Release: 2023-09-06 19:29:02
forward
997 people have browsed it

如何在MySQL DATE_FORMAT()函数中一起使用日期和时间格式字符?

We can use both format characters in the DATE_FORMAT() function. The following example will clarify this -

mysql> SELECT DATE_FORMAT(NOW(), 'The time is %a %h:%i:%s:%f %p');

+-----------------------------------------------------+
| DATE_FORMAT(NOW(), 'The time is %a %h:%i:%s:%f %p') |
+-----------------------------------------------------+
| The time is Sun 06:35:06:000000 AM                  |
+-----------------------------------------------------+
1 row in set (0.00 sec)
Copy after login

The above query uses the date format character "%a" along with other time format characters.

The following is another example of using both formatting characters -

mysql> SELECT DATE_FORMAT(NOW(), 'The date & time is %a %D %M %Y %h:%i:%s:%f %p');

+---------------------------------------------------------------------+
| DATE_FORMAT(NOW(), 'The date & time is %a %D %M %Y %h:%i:%s:%f %p') |
+---------------------------------------------------------------------+
| The date & time is Sun 29th October 2017 06:37:17:000000 AM         |
+---------------------------------------------------------------------+
1 row in set (0.00 sec)
Copy after login

The above is the detailed content of How to use date and time format characters together in MySQL DATE_FORMAT() function?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template