如何在PHP中创建今天为MM/DD/YYYY格式的变量? [英] How do I create a variable in PHP of today's date of MM/DD/YYYY format?

查看:86
本文介绍了如何在PHP中创建今天为MM/DD/YYYY格式的变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在PHP中创建今天为MM/DD/YYYY格式的变量?

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

当某人进入该网站时,我需要输入该日期作为隐藏表单字段.因此,我需要获取今天的日期并将其转换为该格式.谢谢.

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.

推荐答案

使用内置的日期()函数.

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

字符串参数'm/d/Y'是返回的日期模式. m表示2位数的月份,d表示2位数的日期值,Y表示4位数的年份值.

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.

这篇关于如何在PHP中创建今天为MM/DD/YYYY格式的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆