Im currently using gildaspk:autoform-materialize and when I write in my schema
date: {
type: Date,
autoform: {
type: "pickadate",
afFieldInput: {
type: "pickadate"
}
}
}
it works very nice when selecting the date, nothing strange whatsoever. However I would also like to select the time. All I can find about this is to use the autoform-bs-datetimepicker package but this means that I have to download the bootstrap package. I don’t want to do this and can’t as the rest of my code is based on materialize. Is there any package out there for materialize/material design that lets you choose date/time simultaneously? Thanks!
Just make an select
element, with allowed times or generate them programmatically! No need for special time picker. This way you can allow/disallow time more easily and do other sorts of custom logic.
I’d rather use this in combination with moment.js later on. How would I then combine the date and time together? Could you provide a very basic example? In mongo when I pick a date I get something like this:
2015-12-21T23:00:00.000Z
Where the time always is T23:00:00.000Z because I not able to pick it. Is it possible to make an options list with only the suggested times and then replace the T23:00:00.000Z with the newly generated time? It seems that there should be a less trickier way to do this.
Thanks.
Well that should not be a problem, upon submit
event parse the value with moment.js and set hour
& minute
manually with .setMinute()
and .setHour()
. To save it back as compatible ISO String use .toISOString()
.
Also you do not even have to use moment.js for this manipulation. You could simple initiate a new Date(pickedDate)
and manipulate it with the native javascript api.
Ok, thanks I will try this out!