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 wo
<?php
$currentdate = date('m/d/Y');
echo "The Current Date is: $currentdate";
?>
<?php
echo "Today is " . date("Y/m/d") . "<br>";
echo "Today is " . date("Y.m.d") . "<br>";
echo "Today is " . date("Y-m-d") . "<br>";
?>
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
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.
$Date = date('m/d/Y');
use the builtin date() function.
$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.
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