CRM 日期类型的一些处理JS

时间:2023-03-09 13:22:07
CRM 日期类型的一些处理JS
//当前日期
var now = new Date();
//换算为毫秒数
var now_ms = Date.UTC( now.getFullYear(), now.getMonth(),now.getDate());
//getMonth 从0-11 所以真实月份要+1, getDate 注意与 getDay的区别,getDate为日, getDay 为周 //计算开始日期
var _form_date =crmForm.all.new_begindate.DataValue ;
//计划开始日期加8 小时
var form_date = new Date(_form_date.setHours(_form_date.getHours()+8));
var form_ms =Date.UTC(form_date.getFullYear(), form_date.getMonth(),form_date.getDate()); if(form_ms < now_ms)
{
//如果计划开始日期小于当前日期禁止保存
crmForm.all.new_begindate.DataValue = new Date();
crmForm.all.new_enddate.DataValue = new Date();
alert("计划开始日期不能小于当前日期!");
}

相关文章