当前位置: 移动技术网 > IT编程>开发语言>JavaScript > bootstrap timepicker在angular中取值并转化为时间戳

bootstrap timepicker在angular中取值并转化为时间戳

2017年12月12日  | 移动技术网IT编程  | 我要评论

上一篇我们讲到angular对于timepicker的一个封装后的插件,但是由于angular的版本必须是v1.2.30以上的。对于有些大型系统,一时升级angular的版本实在耗费时间。那么可以用这种方法来取值。

页面上的时间格式是这样的:

文件引入

'/bootstrap-datetimepicker.min.css',
'/bootstrap-datetimepicker.min.js',
'/bootstrap-datetimepicker.zh-cn.js',//中文包

html

<div 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> 
</div>

js:

 var datefrom = $("#effstartdate input").val();//设置一个id,取到bootstrap timepicker的值
 $scope.effstartdate=new date(datefrom.substring(0,19).replace(/-/g,'/')).gettime()/1000;//转化为时间戳

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网