Home  >  Article  >  Backend Development  >  新手问题 - 在mysql/php中,怎么改变日期输入的格式?

新手问题 - 在mysql/php中,怎么改变日期输入的格式?

WBOY
WBOYOriginal
2016-06-06 20:52:341003browse

我是用 now() 这个函数来把现在的时间读到数据库中的,输出之后显示的是 「2011-10-10 10:47:39」

我现在只需要 「10:47:39」这么多,请问怎么修改?

回复内容:

我是用 now() 这个函数来把现在的时间读到数据库中的,输出之后显示的是 「2011-10-10 10:47:39」

我现在只需要 「10:47:39」这么多,请问怎么修改?

给你个通用的解决方法吧

$input = '2011-10-10 10:47:39';
$output = date('H:i:s', strtotime($input));
echo $output;
Statement:
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