Home >Web Front-end >JS Tutorial >How to convert timepicker into timestamp in angular?
This article mainly introduces the method of bootstrap timepicker to obtain the value in Angular and convert it into a timestamp. It has a certain reference value. Interested friends can refer to the previous article.
We talked about Go to angular for a packaged plug-in for timepicker, but the version of angular must be v1.2.30 or above. For some large systems, upgrading the angular version at once is very time-consuming. Then you can use this method to get the value.
The time format on the page is like this:
File introduction
'/bootstrap-datetimepicker.min.css', '/bootstrap-datetimepicker.min.js', '/bootstrap-datetimepicker.zh-CN.js',//中文包
html
<p class="input-group date form_datetime" data-date-format="yyyy-mm-dd hh:ii:ss" data-link-field="dtp_input1" id="effStartDate"> //设置时间格式为 yyyy-mm-dd hh:ii:ss 。设置ID为 effStartDate <input class="form-control" size="16" type="text" value="" readonly> <span class="input-group-addon"> <span class="glyphicon glyphicon-remove"></span> </span> <span class="input-group-addon"> <span class="glyphicon glyphicon-th"></span> </span> </p>
js:
var dateFrom = $("#effStartDate input").val();//设置一个ID,取到bootstrap timepicker的值 $scope.effStartDate=new Date(dateFrom.substring(0,19).replace(/-/g,'/')).getTime()/1000;//转化为时间戳
The above is the detailed content of How to convert timepicker into timestamp in angular?. For more information, please follow other related articles on the PHP Chinese website!