js字符串格式化时间
2014-11-06 19:54
351 查看
if (data && data != "") {
$.each(data,function(i, vote){
var beginTime = vote.beginTime;
var endTime = vote.endTime;
var sTime = new Date(Date.parse(beginTime.replace(/-/g,"/"))); //开始时间
var eTime = new Date(Date.parse(endTime.replace(/-/g,"/"))); //结束时间
var nowTime = new Date();
if (nowTime.getTime() > sTime.getTime() && nowTime.getTime() < eTime.getTime()) {
str += "<tr><td class='alignleft'><a href='${ctx}/survey/vote.do?action=vote&vote.id=" + vote.id + "'>" + vote.theme + "</a><span style='color:#0000ff;'> 正在进行</span></td></tr>";
} else if(nowTime.getTime() > eTime.getTime()) {
str += "<tr><td class='alignleft'><a href='${ctx}/survey/vote.do?action=vote&vote.id=" + vote.id + "'>" + vote.theme + "</a><span class='red'> 已结束</span></td></tr>";
} else {
str += "<tr><td class='alignleft'><a href='${ctx}/survey/vote.do?action=vote&vote.id=" + vote.id + "'>" + vote.theme + "</a><span> 未开始</span></td></tr>";
}
});
}
function initVoteInfo() {
var url = "${ctx}/survey/vote.do";
$.post(url,
{
"action" : "voteInfo"
},
function(object){
if (object.code == 0) {
var str = "";
var data = object.data;
if (data && data != "") {
$.each(data,function(i, vote){
var beginTime = vote.beginTime;
var endTime = vote.endTime;
var sTime = new Date(Date.parse(beginTime.replace(/-/g,"/"))); //开始时间
var eTime = new Date(Date.parse(endTime.replace(/-/g,"/"))); //结束时间
var nowTime = new Date();
if (nowTime.getTime() > sTime.getTime() && nowTime.getTime() < eTime.getTime()) {
str += "<tr><td class='alignleft'><a href='${ctx}/survey/vote.do?action=vote&vote.id=" + vote.id + "'>" + vote.theme + "</a><span style='color:#0000ff;'> 正在进行</span></td></tr>";
} else if(nowTime.getTime() > eTime.getTime()) {
str += "<tr><td class='alignleft'><a href='${ctx}/survey/vote.do?action=vote&vote.id=" + vote.id + "'>" + vote.theme + "</a><span class='red'> 已结束</span></td></tr>";
} else {
str += "<tr><td class='alignleft'><a href='${ctx}/survey/vote.do?action=vote&vote.id=" + vote.id + "'>" + vote.theme + "</a><span> 未开始</span></td></tr>";
}
});
}
if (str == "") {
str += "<tr><td>暂无投票信息!</td></tr>";
}
$("#voteTable").append(str);
}
},"json");
}
$.each(data,function(i, vote){
var beginTime = vote.beginTime;
var endTime = vote.endTime;
var sTime = new Date(Date.parse(beginTime.replace(/-/g,"/"))); //开始时间
var eTime = new Date(Date.parse(endTime.replace(/-/g,"/"))); //结束时间
var nowTime = new Date();
if (nowTime.getTime() > sTime.getTime() && nowTime.getTime() < eTime.getTime()) {
str += "<tr><td class='alignleft'><a href='${ctx}/survey/vote.do?action=vote&vote.id=" + vote.id + "'>" + vote.theme + "</a><span style='color:#0000ff;'> 正在进行</span></td></tr>";
} else if(nowTime.getTime() > eTime.getTime()) {
str += "<tr><td class='alignleft'><a href='${ctx}/survey/vote.do?action=vote&vote.id=" + vote.id + "'>" + vote.theme + "</a><span class='red'> 已结束</span></td></tr>";
} else {
str += "<tr><td class='alignleft'><a href='${ctx}/survey/vote.do?action=vote&vote.id=" + vote.id + "'>" + vote.theme + "</a><span> 未开始</span></td></tr>";
}
});
}
function initVoteInfo() {
var url = "${ctx}/survey/vote.do";
$.post(url,
{
"action" : "voteInfo"
},
function(object){
if (object.code == 0) {
var str = "";
var data = object.data;
if (data && data != "") {
$.each(data,function(i, vote){
var beginTime = vote.beginTime;
var endTime = vote.endTime;
var sTime = new Date(Date.parse(beginTime.replace(/-/g,"/"))); //开始时间
var eTime = new Date(Date.parse(endTime.replace(/-/g,"/"))); //结束时间
var nowTime = new Date();
if (nowTime.getTime() > sTime.getTime() && nowTime.getTime() < eTime.getTime()) {
str += "<tr><td class='alignleft'><a href='${ctx}/survey/vote.do?action=vote&vote.id=" + vote.id + "'>" + vote.theme + "</a><span style='color:#0000ff;'> 正在进行</span></td></tr>";
} else if(nowTime.getTime() > eTime.getTime()) {
str += "<tr><td class='alignleft'><a href='${ctx}/survey/vote.do?action=vote&vote.id=" + vote.id + "'>" + vote.theme + "</a><span class='red'> 已结束</span></td></tr>";
} else {
str += "<tr><td class='alignleft'><a href='${ctx}/survey/vote.do?action=vote&vote.id=" + vote.id + "'>" + vote.theme + "</a><span> 未开始</span></td></tr>";
}
});
}
if (str == "") {
str += "<tr><td>暂无投票信息!</td></tr>";
}
$("#voteTable").append(str);
}
},"json");
}
相关文章推荐
- js中格式化时间字符串
- js 定时跳转, 格式化字符串时间
- js中格式化时间字符串
- js格式化日期字符串进行时间比较
- js扩展Date将时间格式化为"yyyy-MM-dd hh:mm:ss"格式的字符串
- js 将时间戳格式化为 yyyy-MM-dd HH:mm:ss 格式的字符串
- js中格式化时间字符串
- js将格式化后的时间拼接成字符串
- 时间字符串格式化 js
- js中格式化时间字符串
- 表单序列化json字符串和js时间格式化
- js时间格式化工具,时间戳格式化,字符串转时间戳
- js中格式化时间字符串
- 在js中对时间类型格式化字符串
- js中格式化时间字符串
- js强大的日期格式化,timestamp支持10位或13位的时间戳,或是时间字符串
- js中截取无特殊符号的字符串和取得特殊时间
- [收藏] C# 格式化时间字符串
- #时间格式化字符串详解
- C#格式化字符串,日期,时间,货币