ankurk91 / vue-bootstrap-datetimepicker

Vue.js component for eonasdan bootstrap datetimepicker
MIT License
223 stars 66 forks source link
bootstrap datepicker vue vue-bootstrap-datetimepicker vue-component

Vue Bootstrap 4 DatetimePicker

vue-js downloads npm-version github-tag license build-status codecov

Vue.js component for eonasdan-bootstrap-datetimepicker

Demo on JSFiddle

Versions

:point_right: If you are looking for the documentation of an older version then switch to respective version branch.

Package Version Bootstrap CSS version Underlying Library API Docs (same for both)
4.x 3.x eonasdan-bootstrap-datetimepicker (Official) Docs
5.x 4.x pc-bootstrap4-datetimepicker (Fork) Docs

Features

Requirements

Installation

# npm
npm install vue-bootstrap-datetimepicker --save

# Yarn
yarn add vue-bootstrap-datetimepicker

Using Webpack?

Using Laravel Mix?

Icon Fonts missing?

Usage Example

<template>
  <div class="container">
    <div class="row">
      <div class="col-md-12">
        <date-picker v-model="date" :config="options"></date-picker>
      </div>
    </div>
  </div>
</template>

<script>
  // Import required dependencies 
  import 'bootstrap/dist/css/bootstrap.css';

  // Import this component
  import datePicker from 'vue-bootstrap-datetimepicker';

  // Import date picker css
  import 'pc-bootstrap4-datetimepicker/build/css/bootstrap-datetimepicker.css';

  export default {    
    data () {
      return {
        date: new Date(),
        options: {
          format: 'DD/MM/YYYY',
          useCurrent: false,
        }       
      }
    },
    components: {
      datePicker
    }
  }
</script>

As plugin

  import Vue from 'vue';
  import datePicker from 'vue-bootstrap-datetimepicker';
  import 'bootstrap/dist/css/bootstrap.css';
  import 'pc-bootstrap4-datetimepicker/build/css/bootstrap-datetimepicker.css';
  Vue.use(datePicker);

This will register a global component <date-picker>

Events

Available props

The component accepts these props:

Attribute Type Default Description
v-model / value String / Date Object / moment / null null Set or Get date-picker value
config Object {} Datetime picker configuration options
wrap Boolean false Set this to true when wrapped in 'input-group'

Install in non-module environments (without webpack)

<!-- Date-picker dependencies -->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.3"></script>
<script src="https://cdn.jsdelivr.net/npm/moment@2.22"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/css/bootstrap.min.css" rel="stylesheet">

<!-- Date-picker itself -->
<script src="https://cdn.jsdelivr.net/npm/pc-bootstrap4-datetimepicker@4.17/build/js/bootstrap-datetimepicker.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/pc-bootstrap4-datetimepicker@4.17/build/css/bootstrap-datetimepicker.min.css" rel="stylesheet">

<!-- Vue js -->
<script src="https://cdn.jsdelivr.net/npm/vue@2.5"></script>
<!-- Lastly add this package -->
<script src="https://cdn.jsdelivr.net/npm/vue-bootstrap-datetimepicker@5"></script>
<script>
  // Initialize as global component
  Vue.component('date-picker', VueBootstrapDatetimePicker);
</script>

Run examples on your localhost

Testing

Changelog

Please see CHANGELOG for more information what has changed recently.

Caveats

License

MIT License