A valid date-time as defined in RFC 3339 with these additional qualifications:
the literal letters T and Z in the date/time syntax must always be uppercase the date-fullyear production is instead defined as four or more digits representing a number greater than 0 Examples
1990-12-31T23:59:60Z 1996-12-19T16:39:57-08:00
Solution
To create RFC 3339 format in PHP you can use:
echo date('Y-m-d\TH:i:sP', $row['Time']);
or in another way:
echo date("c", strtotime($row['Time']));
or if you prefer objective style:
echo (new DateTime($row['Time']))->format('c');
<input type="datetime-local" value="<?php echo date('Y-m-d\TH:i:sP', $row['Time']); ?>" class="date" name="start" REQUIRED>
Use links for more info
You need to make sure that the format the date
variable is printing out is valid for the HTML input you want to use.
If it is not (which is what I believe the issue is), then you will need to modify your date/time
variable so that it prints in the correct format.
From the picture it looks like you simply want Hours:Minutes Seconds
. Is this correct to assume?
<?php
//Optional if you wish to set your timezone
date_default_timezone_set('GMT');
// This would print the format 2021-09-07 11:04:48
echo date("Y-m-d,h:m:s");
//You probably want to adjust it to something like this
echo date("h:m s");
?>
So to answer your question: Replace your PHP code (
) with this, and it should be in the correct format.<?php echo date('h:i A',time()); ?>
<?php echo date("h:ms); ?>
if in database time stored like this "20:18" Simply Do the
<input type="time" class="form-control" name="activity_time" placeholder="Activity Time" value="<?php echo date('h:i') ?>" required />
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.