Use strtotime()
and date()
:
(使用strtotime()
和date()
:)
$originalDate = "2010-03-21";
$newDate = date("d-m-Y", strtotime($originalDate));
(See the strtotime and date documentation on the PHP site.)
((请参阅PHP网站上的strtotime和date文档。))
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 and format :-) (为了进行更广泛的转换,您实际上应该使用DateTime
类来解析和格式化:-))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…