<div class="layui-inline" id="AItem"> <label class="layui-form-label syn-form-item-require">公布时间:</label> <div class="layui-input-block"> <input type="text" name="A" id="A" class="layui-input" > </div> </div>
1 // 使用AJAX请求来获取时间配置字符串 2 $.ajax({ 3 url: "/你的url", 4 method: "GET", 5 success: function(response) { 6 var config = response; // 获取时间配置字符串 比如1#2 (意思隔天2点) 7 var currentDate = new Date(); 8 var configArr = config.split("#"); 9 var configDay = parseInt(configArr[0]); 10 var configTime = parseInt(configArr[1]); 11 12 var nextDate = new Date(currentDate.getTime() + configDay * 24 * 60 * 60 * 1000); 13 nextDate.setHours(configTime, 0, 0, 0); 14 15 var defaultValue = nextDate.getFullYear() + '-' + (nextDate.getMonth() + 1) + '-' + nextDate.getDate() + ' ' + configTime + ':00:00'; 16 17 laydate.render({ 18 elem: '#A', 19 trigger: 'click', 20 type: 'datetime', 21 format: 'yyyy-MM-dd HH:mm:ss', 22 value: defaultValue, 23 ready: function () { 24 // 日期选择器准备就绪的回调函数 25 } 26 }); 27 }, 28 error: function() { 29 console.log("获取时间配置失败"); 30 } 31 });
@GetMapping("/timeConfig") @ControllerEndpoint(operation = "获取时间配置成功",exceptionMessage = "获取时间配置失败") public SynResponse getTimeConfig() { <T> daysConfig = this.Service.find时间Config(); return new SynResponse().success().data(时间Config); }
标签:Java,后端,配置,默认,获取,时间,nextDate,var,new From: https://www.cnblogs.com/synn/p/17597311.html