Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

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.

like image 648
Satchel Avatar asked Jul 16 '09 05:07

Satchel


People also ask

How can I get current date in dd-mm-yyyy format in php?

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: " .

How do I +1 a date in php?

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.

Which php function do you use to format date information?

The date_format() function returns a date formatted according to the specified format.

How do I format in php?

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: ".


1 Answers

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 
like image 77
Kalpesh Desai Avatar answered Oct 04 '22 11:10

Kalpesh Desai