码迷,mamicode.com
首页 > 其他好文 > 详细

时间加减设置

时间:2018-09-11 17:05:40      阅读:711      评论:0      收藏:0      [点我收藏+]

标签:mac   code   ons   console   height   时间   theme   fun   format   

<li class="clearfix">
<span class="s1 fl" style="line-height: 0.4rem;">年检日期:</span>
<span class="s2 machine-date">
<input type="text" name="date" id="surveyDate1" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" lay-key="2">
</span>
</li>
<li class="clearfix">
<span class="s1 fl" style="line-height: 0.4rem;">有限截止日期:</span>
<span class="s2 machine-date fl">
<input type="text" name="date" id="expirationDate1" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" lay-key="3">
</span>
</li>
layui.use([‘laydate‘], function(){
var laydate = layui.laydate;

    var datetime=new Date();//获取系统当前时间
    var datetimeNextYear = new Date(datetime);
    datetimeNextYear.setFullYear(datetime.getFullYear()+1);
    datetimeNextYear.setDate(datetimeNextYear.getDate()-1);
    //日期
    laydate.render({
        elem: ‘#expirationDate1‘
        ,value: datetimeNextYear
        ,format: ‘yyyy-MM-dd‘
        ,theme: ‘#128af1‘
        ,done: function(value, date, endDate){
            console.log(value)
            var datetimeNextYear = new Date(value);
            datetimeNextYear.setFullYear(datetimeNextYear.getFullYear()-1);
            datetimeNextYear.setDate(datetimeNextYear.getDate()+1);
            laydate.render({
                elem: ‘#surveyDate1‘
                ,value: datetimeNextYear
                ,format: ‘yyyy-MM-dd‘
            });
        }
    });
    laydate.render({
        elem: ‘#surveyDate1‘
        ,value: new Date(new Date().getTime())
        ,format: ‘yyyy-MM-dd‘
        ,theme: ‘#128af1‘
        ,done: function(value, date, endDate){
            console.log(value)
            var datetimeNextYear = new Date(value);
            datetimeNextYear.setFullYear(datetimeNextYear.getFullYear()+1);
            datetimeNextYear.setDate(datetimeNextYear.getDate()-1);
            laydate.render({
                elem: ‘#expirationDate1‘
                ,value: datetimeNextYear
                ,format: ‘yyyy-MM-dd‘
            });
        }
    });
});

时间加减设置

标签:mac   code   ons   console   height   时间   theme   fun   format   

原文地址:http://blog.51cto.com/13507333/2173859

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!