Petro Gromovo
Petro Gromovo

Reputation: 2173

How to set timezone in vue2-datepicker?

In vuejs 2.6 app I use https://github.com/mengxiong10/vue2-datepicker/ with time select options :

    <date-picker
        v-model="hostelExtraDetails.reception_hours_start"
        type="time"
        :time-picker-options="timePickerOptions"
        id="cbx_extra_details_reception_hours_start"
        :lang="'en'"
        :type="'time'"
        :format="'hh:mm'"
        :header="'HTRF'"
        :placeholder="'Select time from picker'"
    ></date-picker>

import Vue from 'vue';

import moment from 'moment-timezone'
moment.tz.setDefault('Europe/Kiev')


import DatePicker from 'vue2-datepicker' // https://github.com/mengxiong10/vue2-datepicker


export default {
    name: 'new',
    components: {DatePicker}, // https://github.com/mengxiong10/vue2-datepicker

    data() {
        return {
        ...
            timePickerOptions: {
                start: '00:00',
                step: '00:10',
                end: '23:50'
            },

        loadData() {
            this.hostelExtraDetails.reception_hours_start = // I need time value into valid datetime value 
                this.stringIntoDatetime("2019-04-17 " + response.data.hostelExtraDetails.reception_hours_start)

The thing is that selecting some time in picker I see 3 hours difference in model var. I suppose that timezone is not set and which is the valid way setting timezone ?

2) as I need time value into valid datetime value I have a value like "2019-04-17T06:50:00.000Z", Which is simple way to get hours:minutes value from it ?

Upvotes: 5

Views: 9678

Answers (1)

Petro Gromovo
Petro Gromovo

Reputation: 2173

I found a decision in adding property:

<date-picker
    valueType="format"
    ...
></date-picker>

and it works!

Upvotes: 3

Related Questions