本文介绍了字符串日期当前日期/时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 $ date = date(DM d,YG:i);
。
当我回显 $ date
时,会显示正确的日期/时间。现在我需要这个字符串。
When I echo $date
, it shows the correct date/time. Now I need this as an string.
我尝试过 string($ date)
但这里什么也没有。而且
I have tried string($date)
; but nothing happens here. And
$today = strtotime($date);
这里我得到奇怪的数字..
here I get weird numbers..
我需要一个字符串,所以我可以在消息中放入 $ today
。
I need a string so I can put $today
in a message.
这是什么正确的方法
推荐答案
函数已经返回一个字符串。
The date()
function already returns a string.
这样做:
$date = date("D M d, Y G:i");
您将在 $ date
变量,作为字符串 - 不需要任何其他操作。
You'll have the current date in the $date
variable, as a string -- no need for any additional operation.
这篇关于字符串日期当前日期/时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!