Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJs get Timestamp from a human readable date

Is there a way in angular JS to get Timestamp from a date obtained by a form?

<label for="start">From:</label>
<input type="date" ng-model="startDate" />

What will I have to write in the directive to transform this data? I didn't find anything about this particular issue, Regards

like image 511
alessandrob Avatar asked Dec 01 '22 19:12

alessandrob


1 Answers

Since you are using input type as date, the string in model should be compatible with Date object in javascript. So you can do

var timestamp = new Date($scope.startDate).getTime()

like image 130
Chandermani Avatar answered Dec 04 '22 10:12

Chandermani