php mm/dd/yyyy,如何在今天的MM / DD / YYYY格式日期以PHP創建變量?

How do I create a variable in PHP of today's date of MM/DD/YYYY format?

如何在今天的MM / DD / YYYY格式日期以PHP創建變量?

I need to input that date as a hidden form field when someone comes onto the site. So I would need to grab today's date and convert it into that format. Thanks.

當有人進入網站時,我需要將該日期輸入為隱藏的表單字段。所以我需要抓住今天的日期並將其轉換為該格式。謝謝。

5 个解决方案

#1

31

use the builtin date() function.

使用builtin date()函數。

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

the string parameter 'm/d/Y' is the returned date pattern. m is for 2 digit months, d for 2 digit day value and Y for 4 digit year value.

字符串參數'm / d / Y'是返回的日期模式。 m表示2個數字月份,d表示2位數日值,Y表示4位數年份值。

#2

10

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

#3

6

What about using the function date ? Just have to find the right format ; 'm' for month, 'd' for day, 'Y' for year using four digits, for instance

使用功能日期怎么樣?只需找到正確的格式; '是'月份,'d'代表白天,'Y'代表年份,例如四位數

In your case, something like this, I guess :

在你的情況下,我猜這樣的事情:

date("m/d/Y")

And if you want another day than now, use the second optional parameter.

如果你想要比現在更多的一天,請使用第二個可選參數。

#4

1

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

echo "The Current Date is: $currentdate";

?>

#5

1

May be this one help you :)

可能這一個幫你:)

<?php echo $todaydate = date('m/d/Y'); ?> // 04/27/2016

<?php echo $todaydate = date('m/d/y'); ?> // 04/27/16

<?php echo $todaydate = date('Y'); ?> // 2016

<?php echo $todaydate = date('Y-m-d'); ?> // 2016-04-27

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值