简体   繁体   中英

Jquery datepicker date format

How do I get my date to display like this: "yy-mm-dd" inside my date input textbox after I have selected a date?

Information is reading from a database. So I need it saved in a database again.

JavaScript:

<script>
  $(document).ready(function() {
  $("#from").datepicker();
});
</script>

Html code:

<div class="field">
        <label>Date</label>
       <input type="text" name="date" value="<?php value('date'); ?>" id="from" />   
        <?php if(isset($errors['date'])) { ?>
        <div class="error"><?php echo $errors['date']; ?></div>
        <?php } ?>
 </div>

Things that I have tried:

http://docs.jquery.com/UI/Datepicker#option-dateFormat

http://docs.jquery.com/UI/Datepicker/formatDate

jQuery UI DatePicker - Date Format

jquery ui datepicker date format

Define the format during initialization

$("#from").datepicker({
    dateFormat: 'yy-mm-dd'
});

The value is updated as well. See an example .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM