Skip to content

Picker won't open with previously picked datetime #147

Description

@petertenhoor

Hi there,

I am using the material datetime picker to save dates in DD-MM-YYY format. It works fine, but I can't get the picker to open with another default date as the the current date.

My attempt:

import MaterialDatePicker from "material-datetime-picker";
import moment from "moment";

        const input = $el
        const picker = new MaterialDatePicker(
            {
                default: moment(),
                format:  'DD-MM-YYYY',
                value:   (input.value !== '' ? input.value : moment()) //attempt 1 to set input value as picker value
            })
            .on('submit', (val) => {
                input.value = val.format("DD-MM-YYYY")
            });

        input.addEventListener('focus', () => {
            picker.open()

            //attempt 2 to set input value as picker value
            picker.value = input.value
        })

input.value is a date string in MM-DD-YYY format, which i'd like to open as the default picker value. Is this possible and if so; how does one achieve this?

Best regards,

Peter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions