js判断两个时间的大小
function checkdate()
{
//得到日期值并转化成日期格式,replace(//-/g, "//")是根据验证表达式把日期转化成长日期格式,这样
//再进行判断就好判断了
var sDate = new Date(document.getElementById("txtstart").value.replace(//-/g, "//"));
var eDate = new Date(document.getElementById("txtend").value.replace(//-/g, "//"));
if(sDate > eDate)
{
alert("结束日期不能小于开始日期");
return false;
}
return true;
}
取2个时间相隔的大小
TimeSpan ts1 = new TimeSpan(time1.Ticks);
// TimeSpan ts2 = new TimeSpan(ftime2.Ticks);
// TimeSpan ts = ts1.Subtract(ts2).Duration();
// if (int.Parse(ts.Days.ToString()) > 0)
// {
// dateDiff += ts.Days.ToString() + "天";
// }
// if (int.Parse(ts.Hours.ToString()) > 0)
// {
// dateDiff += ts.Hours.ToString() + "小时";
// }
// if (int.Parse(ts.Minutes.ToString()) > 0)
// {
// dateDiff += ts.Minutes.ToString() + "分钟";
// }
3.
<form id="pagerForm" commandName="searchPatent" action="${pageContext.request.contextPath}/manage/busi/artistsinfo_applicpasslist.action?filter_EQS_status_code=02" method="post" οnsubmit="return dateNavTabSearch(this);">
<span>
出生年份:
<input id="birth_date_time_begin" class="date timeBegin" timeWarn="出生年份" size="10" dateFmt="yyyy-MM-dd" name="filter_GES_artist_birth_year" value="${param['filter_GES_artist_birth_year'] }" />
至
<input id="birth_date_time_end" class="date timeEnd" size="10" dateFmt="yyyy-MM-dd" name="filter_LES_artist_birth_year" value="${param['filter_LES_artist_birth_year'] }" />
</span>
/**
* 处理navTab上的查询, 会重新载入当前navTab (时间检索条件 wjh)
* @param {Object} form
*/
function dateNavTabSearch(form, navTabId){
var $form = $(form);
var i=0;
var flag=false;
$form.find(".timeBegin").each(function(){
var sDate = new Date($(this).val().replace(/\-/g, "\/"));
var eDate = new Date($form.find(".timeEnd").eq(i).val().replace(/\-/g, "\/"));
if(sDate > eDate)
{
alert($(this).attr("timeWarn")+"对应结束日期不能小于开始日期!");
flag=true;
}
i++;
});
if(flag)
return false;
var $form = $(form);
if (form[DWZ.pageInfo.pageNum]) form[DWZ.pageInfo.pageNum].value = 1;
navTab.reload($form.attr('action'), {data: $form.serializeArray(), navTabId:navTabId});
return false;
}
/**
* 处理navTab上的查询, 会重新载入当前navTab (时间检索条件 wjh)
* @param {Object} form
*/
function dateNavTabSearch(form, navTabId){
var $form = $(form);
var i=0;
var flag=false;
$form.find(".timeBegin").each(function(){
var sDate = new Date($(this).val().replace(/\-/g, "\/"));
var eDate = new Date($form.find(".timeEnd").eq(i).val().replace(/\-/g, "\/"));
if(sDate > eDate)
{
alert($(this).attr("timeWarn")+"对应结束日期不能小于开始日期!");
flag=true;
}
i++;
});
if(flag)
return false;
var $form = $(form);
if (form[DWZ.pageInfo.pageNum]) form[DWZ.pageInfo.pageNum].value = 1;
navTab.reload($form.attr('action'), {data: $form.serializeArray(), navTabId:navTabId});
return false;
}