Home > Web Front-end > JS Tutorial > How to convert timepicker into timestamp in angular?

How to convert timepicker into timestamp in angular?

零下一度
Release: 2018-05-14 16:24:29
Original
2141 people have browsed it

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',//中文包
Copy after login

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>
Copy after login

js:

 var dateFrom = $("#effStartDate input").val();//设置一个ID,取到bootstrap timepicker的值
 $scope.effStartDate=new Date(dateFrom.substring(0,19).replace(/-/g,&#39;/&#39;)).getTime()/1000;//转化为时间戳
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template