更新时间:2022-03-19 01:43:35
使用 strtotime()
和 date() code>:
Use strtotime()
and date()
:
$originalDate = "2010-03-21";
$newDate = date("d-m-Y", strtotime($originalDate));
(请参阅 strtotime 和 date 文档在PHP网站上)。
(see strtotime and date docs on the PHP site).
修改:请注意,这是对原始问题的快速解决方案。对于更广泛的转化,您应该真正使用 DateTime
类来解析&格式: - )
Edit: Note that this was a quick solution to the original question. For more extensive conversions, you should really be using the DateTime
class to parse & format :-)