使用 PHP 将日期转换为字符串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12598863/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Convert Date to string using PHP
提问by Sealongmaly
I have date 2012/09/26. I want to convert it to string using PHP.How do I fix this.Anyone help me please,Thanks.
我有约会2012/09/26。我想使用 PHP 将其转换为字符串。我该如何解决这个问题。请帮助我,谢谢。
回答by Mihai Iorga
That is already a string, do you want to change format ?
那已经是一个字符串,要更改格式吗?
$date = '2012/09/26';
echo date('l jS \of F Y', strtotime($date));
// Wednesday 26th of September 2012
回答by Ryhan
/** * Converts the likes of '2008-12-22' to 'December 22, 2008' */
/** * 将 '2008-12-22' 转换为 'December 22, 2008' */
echo date( "F j, Y", strtotime( $datetime_value ) );
回答by Snake Eyes
Accordingly with http://php.net/manual/ro/function.date.php
相应地与http://php.net/manual/ro/function.date.php
// Shows like: Monday
echo date("l");

