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:

http://www.php.net//manual/en/timezones.php


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -