Element: Disable past dates

Created on 6 Jun 2017  ·  5Comments  ·  Source: ElemeFE/element

How do i disable past dates in the datepicker?

Most helpful comment

hi,you can add disabledDate function in pickerOptions

 pickerOptions: {
                    disabledDate(time) {
                        return time.getTime() < Date.now() - 8.64e7;
                    }
}

All 5 comments

Hello, this issue has been closed because it does not conform to our issue requirements. Please submit issues with issue-generator. More info can be found in #3693.

hi,you can add disabledDate function in pickerOptions

 pickerOptions: {
                    disabledDate(time) {
                        return time.getTime() < Date.now() - 8.64e7;
                    }
}

@jyjunyz It was a helpful comment. For those who didn't get what's "8.64e7", it's just the number of milliseconds of a day. We need to subtract the number from current timestamp so that we don't disable "today".

@jyjunyz Thanks a lot for the comment. It saved me a lot of time.

@jyjunyz Thanks, this worked like a charm.

and thanks from @authlab-frontdev to explain what 8.64e7 mean.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fscardua picture fscardua  ·  3Comments

chao-hua picture chao-hua  ·  3Comments

gengxuelei picture gengxuelei  ·  3Comments

dbskccc picture dbskccc  ·  3Comments

smallpath picture smallpath  ·  3Comments