JSFiddle - React, Tailwind, and code Playground
HTML
<body ng-app="app">
<label for="start">From:</label>
<input type="date" ng-model="startDate" string-to-timestamp />
<div>Timestamp: {{startDate}}</div>
</body>
JavaScript
angular.module('app', [])
.directive('stringToTimestamp', function() {
return {
require: 'ngModel',
link: function(scope, ele, attr, ngModel) {
// view to model
ngModel.$parsers.push(function(value) {
return Date.parse(value);
//return new Date(value).getTime();
});
}
}
});