set datetime value in input html from php -
i try set value datetime input( change current value of variable date time), html show error ( seems it's fault format):
the code :
<input type="datetime" name="deadline" required value ='<?php echo date('c', $datedeadline); ?>'/>
thx lot.
if $datedeadiline indeed defined, should wrap strtotime().
on manual:
string date ( string $format [, int $timestamp = time() ] )
you should provide timestamp, not string date. consider example:
<?php $datedeadiline = '2014-06-21 12:32:00'; ?> <input type="datetime" name="deadline" required value="<?php echo date('c', strtotime($datedeadiline)); ?>" /> using datetime class timezone:
<?php $date = new datetime('2014-06-21 12:32:00', new datetimezone('america/new_york')); ?> <input type="datetime" name="deadline" required value="<?php echo $date->format('c'); ?>" /> for list of supported timezones, can check link:
Comments
Post a Comment