使用 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 03:53:39  来源:igfitidea点击:

Convert Date to string using PHP

phpdatetime

提问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");