Reputation: 418
I'm having an issue using ng-model with time input on my app. I've searched around and couldn't find any other questions regarding this but I may be mistaken.
I have time inputs with ng-model and am getting this weird "1970-01-01T09:00:00.000Z" value.
Here's a fiddle recreating my issue
<div ng-app>
<input type="time" step="900" ng-model="startTime" />
<input type="time" step="900" ng-model="endTime" />
<pre>
Start Time: {{ startTime }}
End Time: {{ endTime }}
</pre>
</div>
Only dependency I'm using is angualr v1.3.15
Upvotes: 1
Views: 1428
Reputation: 17064
You can use the date filter and display the time as you wish, there are many many options. This is one example:
Start Time: {{ startTime | date : 'hh:mm' }}
Upvotes: 0
Reputation: 2596
Looks like you're getting a javascript date, with the time portion set to whatever you selected in the input. It's showing in Zulu time (UTC), so for me if I pick 2:30 AM, it displays 1970-01-01T08:30:00.000Z. Ignore the date portion, the time portion is what I selected.
If you want to see the selected time adjusted to your local time zone, use the date filter.
Start Time: {{ startTime | date:"hh:mm a" }}
End Time: {{ endTime | date:"hh:mm a" }}
Upvotes: 1