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.
php /*print date in dd/mm/yy format*/ print "Current date in dd/mm/yy format: " . date("d/m/y"); print "</br>"; /*print date in dd/mm/yyyy format*/ print "Current date in dd/mm/yyyy format: " . date("d/m/Y"); print "</br>"; /*print date in dd MON yyyy format*/ print "Current date in dd MON yyyy format: " .
php //add day to date test for month roll over $stop_date = date('Y-m-d H:i:s', strtotime("2009-09-30 20:24:00")); echo 'date before day adding: '. $stop_date; $stop_date = date('Y-m-d H:i:s', strtotime('+1 day', $stop_date)); echo ' date after adding one day.
The date_format() function returns a date formatted according to the specified format.
Change YYYY-MM-DD to DD-MM-YYYY In the below example, we have date 2019-09-15 in YYYY-MM-DD format, and we will convert this to 15-09-2019 in DD-MM-YYYY format. $orgDate = "2019-09-15"; $newDate = date("d-m-Y", strtotime($orgDate)); echo "New date format is: ".
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With