I have a date value in PHP
variable $date
which want to show in the input having type date with following code:
<input type="date" value="<?php echo $date;?>" name="date">
I want to show the value which is in $date
variable in the input textbox of date. Also, user should be able to pick the value from the date picker, which is working fine, but i want a date should be there. I looked at previous questions, they assign the today's value, but i want to use the value i have in $date
variable.
You can do something like
<?php
$timestamp = time();
$date = date( "Y-m-d", $timestamp );
?>
<input type="date" value="<?php echo $date; ?>" name="date">
Explanation
date( "Ymd", $timestamp )
formats a timestamp to the appropriate format ( eg 2019-11-29 ).
Resources
Try RMo solution or try.
<input name="date" type="date" value="<?php echo date('F d, Y'); ?>" />
Where:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.