doukenqiong0588 2015-12-02 16:54
浏览 112

自动设置日期输入字段的选项

When presenting a user with a date input form

<input type="date" class="form-control" name="date" value="{{ old('date') }}">

Most of the time although not always the user needs to enter todays date.

What are my options for setting the default value to todays date.

Im using Blade, PHP, Bootstrap, Laravel, CSS, HTML

If any of them resources have something to handle this.

Thanks in advance for any feedback it's appreciated.

  • 写回答

2条回答 默认 最新

  • douju3911 2015-12-02 17:07
    关注

    You can use PHP to echo the date:

    <?php $today = date("m/d/Y"); ?>
    <input type="date" class="form-control" name="date" value="<?php echo $today; ?>">
    

    This will echo a date in the format of Month/Date/Year, e.g. 12/31/2000

    The documentation here explains in more detail on how to format the date

    评论

报告相同问题?