dazhangli
 //ajax()获取 服务器时间
$(function(){
		$.ajax({
        type:"OPTIONS",
        url:"/",
        complete:function(x){
//              alert(x.getResponseHeader("Date"))

        var time = x.getResponseHeader("Date");
        var curDate = new Date(time);
        var year = curDate.getFullYear();
        var month = curDate.getMonth() + 1;
        var day = curDate.getDate();
        var hour = curDate.getHours();
        var minu = curDate.getMinutes();
        var seconds = curDate.getSeconds();
        var millsecond = curDate.getMilliseconds(); //获取服务器毫秒数(0-999)
        if (month < 10) { month = \'0\' + month; }
        if (day < 10) { day = \'0\' + day; }
        if (hour < 10) { hour = \'0\' + hour; }
        if (minu < 10) { minu = \'0\' + minu; }
        if (millsecond < 10) { millsecond = \'0\' + millsecond; }
        if (seconds < 10) { seconds = \'0\' + seconds; }
            var monthtime=parseInt(month)-1;
                if(monthtime==0){
                	year=parseInt(year)-1;
                	monthtime=12;
                }  //设置获取 前一个月
                if(monthtime<10){
                	monthtime=\'0\'+monthtime;
                }
                 $("#formTime").val(year+\'-\'+monthtime);
                  $(\'.report-data\').html(year+\'-\'+monthtime);
                
        }
    })
})

  

分类:

技术点:

相关文章:

  • 2021-11-29
  • 2022-12-23
  • 2021-11-29
  • 2021-12-22
  • 2021-11-29
  • 2021-12-26
  • 2021-10-04
猜你喜欢
  • 2021-11-29
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
相关资源
相似解决方案