How to show Datetime dates should start from Today Dates.Before dates from today should disable.
How to show Datetime dates should start from Today Dates.Before dates from today should disable.
Omniwyse
Posts: 29Questions: 11Answers: 0
I want to have the datetime should be start from today's date earlier date should be grey out.
Example : Yesterday and earlier dates should be grey out.
How to do that ?
This question has an accepted answers - jump to answer
Answers
Use the
minDate
option of thedatetime
field type - e.g.:Allan
Thank Allan for quick reply,
I have added minDate to my date field, Now from Tomorrow onwards I am able to select the date from date picker. But the problem is todays date not able to select from date picker.Actually We should be select from todays date onwards right.
Earlier dates are disables properly. Only the problem I am not able to select todays date only.
This is how I added.
{
label: "Holiday Date :",
name: "stringDate",
data: "stringDate",
type: "datetime",
opts: {
minDate: new Date()
},
displayFormat: "yyyy-MM-DD",
wireFormat: "yyyy-MM-DD"
},
You can jiggle that new date to remove a day from it, with
Please see example here,
Colin
Good catch - and thank you Colin for explaining how to resolve it!
I thought it would be worth writing down here why that is happening (which I've just realised after reading your reply!) -
new Date()
will create aDate
object at the current time - for me that is 14th Sept 2022 08:28:23 at this very moment. DateTime uses00:00:00
as the time for its calculation base, thus that value is not <= now. Doh. Colin's fix works around that.Allan
Thank Colin and Allan