REST查询 datetime类型

1,查询时间类型的时候 时间取值要用UTC时间,转成待定格式的字符串

例如:$filter=new_date ge datetime'2010-09-10T12:00:00' and new_date le datetime'2010-09-12T12:00:00' and new_type/Value ne 100000000

时间转换函数如下 :
function GetUTCDate(date) {
var year = date.getUTCFullYear();
var month = date.getUTCMonth() + 1;
if (month < 10) {
month = "0" + month.toString();
}
var day = date.getUTCDate();
if (day < 10) {
day = "0" + day.toString();
}
var hour = date.getUTCHours();
if (hour < 10) {
hour = "0" + hour.toString();
}
var min = date.getUTCMinutes();
if (min < 10) {
min = "0" + min.toString();
}
var second = date.getUTCSeconds();
if (second < 10) {
second = "0" + second.toString();
}



return year.toString() + "-" + month.toString() + "-" + day.toString() + "T" + hour.toString() + ":" + min.toString() + ":" + second.toString()+"Z";
}

posted @ 2013-03-07 14:54  流浪De云  阅读(190)  评论(0编辑  收藏  举报