CRM JS 日期格式化及时间设置

日期格式化

var myDate = new Date();

var myDate1 = new Date();

myDate1.setMonth(0);

myDate1.setDate(-1);

var rq = myDate -myDate1 ;

var s1 = Math.ceil(rq/(24*60*60*1000));

var s2 = Math.ceil(s1/7);

var nowDayOfWeek = myDate.getDay()-1;         //今天本周的第几天 (由于是显示周一开始,而不是周日开始)

var nowDay = myDate.getDate();                     //当前日

      var nowMonth = myDate.getMonth();           //当前月  

    var nowYear = myDate.getFullYear();         //当前年

 

//设置日志的开始、结束时间
function GetDailylogstarttime()
{
var year=myDate.getFullYear();
var month=myDate.getMonth();
var day=myDate.getDate();
var datestart=new Date(year,month,day,"9","00");
var dateend=new Date(year,month,day,"17","30");
//alert(newdate);
   var PageType=Xrm.Page.ui.getFormType();   //获取页面的类型1创建 2更新 3 查看...
  if(PageType==1)
  {
  Xrm.Page.getAttribute('xz_starttime').setValue(datestart);
  Xrm.Page.getAttribute('xz_endtime').setValue(dateend);
  }
}

posted @ 2014-01-16 16:31  Bill 李  阅读(501)  评论(0编辑  收藏  举报