Skip to content

imanmalekian31/vue3-persian-datetime-picker

 
 

Repository files navigation

persian-datetime-picker-vue (based on dayjs)

npm version

A vue plugin to select jalali date and time based on dayjs

See documentation and demo at vue-persian-datetime-picker.

If you are using vuejs 2, please refer to this repository.

Installation

browser

<script src="https://unpkg.com/vue@next"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.5/dayjs.min.js"></script>
<script src="/dist/persian-datetime-picker-vue.umd.min.js"></script>
<div id="app">
  <date-picker v-model="date"></date-picker>
</div>
<script>
  Vue.createApp({
    data: function() {
      return {
        date: '1400/01/01'
      }
    },
    components: {
      DatePicker: Vue3PersianDatetimePicker
    }
  }).mount('#app')
</script>

npm

npm install persian-datetime-picker-vue --save

Usage

// main.js

import { createApp } from 'vue'
import Vue3PersianDatetimePicker from 'persian-datetime-picker-vue'
const app = createApp({})
app.component('DatePicker', Vue3PersianDatetimePicker)
app.mount('#app')

Or in component

<template>
  <date-picker v-model="date"></date-picker>
</template>

<script>
  import DatePicker from 'persian-datetime-picker-vue'
  export default {
    data() {
      return {
        date: ''
      }
    },
    components: { DatePicker }
  }
</script>

You can also set default values:

// main.js

import Vue3PersianDatetimePicker from 'persian-datetime-picker-vue'
const app = createApp({})
app.use(Vue3PersianDatetimePicker, {
  name: 'CustomDatePicker',
  props: {
    format: 'YYYY-MM-DD HH:mm',
    displayFormat: 'YYYY-MM-DD',
    editable: false,
    inputClass: 'form-control my-custom-class-name',
    placeholder: 'Please select a date',
    altFormat: 'YYYY-MM-DD HH:mm',
    color: '#00acc1',
    autoSubmit: false
    //...
    //... And whatever you want to set as default.
    //...
  }
})

Then use in component

<custom-date-picker v-model="date"></custom-date-picker>

License

This project is licensed under the MIT License

About

A vue plugin to select jalali date and time

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Vue 66.7%
  • JavaScript 16.7%
  • SCSS 16.0%
  • HTML 0.6%