如何让今天的日期出现在PHP中?

时间:2022-11-29 22:53:15

I'm sending a mail function to myself.

我正在给自己发送邮件功能。

My first line reads 'Order for $name on $date' The $name variable comes from a form the user fills out. I would like the $date variable to be today's date, whatever that is on that day.

我的第一行是'在$ date上订购$ name'$ name变量来自用户填写的表单。我希望$ date变量是今天的日期,无论那天是什么。

How can I make the $date variable show today's date?

如何让$ date变量显示今天的日期?

3 个解决方案

#1


$date = date('m/d/Y');

see http://en.php.net/manual/en/function.date.php for the syntax of date()

有关date()的语法,请参见http://en.php.net/manual/en/function.date.php

#2


http://us3.php.net/manual/en/function.date.php The date() function does that.

http://us3.php.net/manual/en/function.date.php date()函数可以做到这一点。

#3


This puts today's date in a string, all ready to be stuck into the DB :).

这将今天的日期放在一个字符串中,所有这些都准备好插入DB :)。

$todays_date_string = date("Y-m-d H:i:s"); 

#1


$date = date('m/d/Y');

see http://en.php.net/manual/en/function.date.php for the syntax of date()

有关date()的语法,请参见http://en.php.net/manual/en/function.date.php

#2


http://us3.php.net/manual/en/function.date.php The date() function does that.

http://us3.php.net/manual/en/function.date.php date()函数可以做到这一点。

#3


This puts today's date in a string, all ready to be stuck into the DB :).

这将今天的日期放在一个字符串中,所有这些都准备好插入DB :)。

$todays_date_string = date("Y-m-d H:i:s");