您现在的位置: 首页 > 资讯 > 互联网知识 > 网页开发常用的时间选择器代码

网页开发常用的时间选择器代码

互联网知识2022-07-18 13:26:20ddcweb262
请选择要计算的日期: layui.use(['util', 'laydate', 'layer'], function(){ var util = layui.util ,laydate = layui.laydate ,$ = layui.$ ,layer = layui.layer; //
请选择要计算的日期:
请选择要计算的日期:
<div class="layui-inline">
<input class="layui-input" id="test3" type="text" />
</div>
<script>
layui.use(['util', 'laydate', 'layer'], function(){
  var util = layui.util
  ,laydate = layui.laydate
  ,$ = layui.$
  ,layer = layui.layer;
  //固定块
  util.fixbar({
    bar1: true
    ,bar2: true
    ,css: {right: 50, bottom: 100}
    ,bgcolor: '#393D49'
    ,click: function(type){
      if(type === 'bar1'){
        layer.msg('icon 是可以随便换的')
      } else if(type === 'bar2') {
        layer.msg('两个 bar 都可以设定是否开启')
      }
    }
  });
 //某个时间在当前时间的多久前
  var setTimeAgo = function(y, M, d, H, m, s){
    var str = util.timeAgo(new Date(y, M||0, d||1, H||0, m||0, s||0));
    lay('#test4').html(str);
  };
  laydate.render({
    elem: '#test3'
    ,type: 'datetime'
    ,done: function(value, date){
      setTimeAgo(date.year, date.month - 1, date.date, date.hours, date.minutes, date.seconds);
    }
  });
    
});
</script>
本文标签:
售前咨询
售后咨询
技术咨询
扫一扫

全国免费服务热线
13712877293

返回顶部