material icon indicating copy to clipboard operation
material copied to clipboard

Preserve time when selecting a date using the datepicker

Open remcohaszing opened this issue 11 years ago • 7 comments

The mdDatepicker directive resets the time when selected. It would be useful if this would be preserved on a form where a user may select an entire datetime. This is also how an <input type="date"/> element works.

The following example allows setting the date and time using the input fields. When the mdDatepicker is used, the time is reset.

<md-datepicker ng-model="vm.datetime"></md-datepicker>
<md-input-container md-no-float>
  <md-icon md-font-icon="mdi-clock"></md-icon>
  <input type="date" ng-model="vm.datetime" aria-label="Time"/>
</md-input-container>
<md-input-container md-no-float>
  <md-icon md-font-icon="mdi-clock"></md-icon>
  <input type="time" ng-model="vm.datetime" aria-label="Time"/>
</md-input-container>
{{vm.datetime}}

remcohaszing avatar Oct 29 '15 11:10 remcohaszing

+1

Pelu2k12 avatar Nov 03 '15 22:11 Pelu2k12

+1

TheRealBryon avatar Nov 03 '15 22:11 TheRealBryon

+1

ThomasvLingen avatar Nov 04 '15 16:11 ThomasvLingen

+1

cleever avatar Nov 18 '15 19:11 cleever

+1

CreativelyMe avatar Jan 10 '16 17:01 CreativelyMe

Why was this deprecated? it's clearly bad behavior and makes for a lot of repeated (and annoying) code

Lacrymology avatar Sep 28 '16 09:09 Lacrymology

At least some kind of explanation would be nice

Lacrymology avatar Sep 28 '16 09:09 Lacrymology