日期:2014-05-19  浏览次数:20424 次

AjaxPro.2 显示日期的问题 高手来啊! 只能给这么点分了~~


后台方法:
        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)]
        public   DataSet   Message(string   strUserID)
        {
              DataSet   ds   =   new   DataSet   ();
              ...
              ...
//ds.Tables[0].Rows[0][ "DataTime "].ToString();     值:2007-05-15   15:28:47.560
              return   ds;
        }

JS中:

var   dialogID   =   document.location.search.split( '= ')[1];
var   ds   =   GetMessage(dialogID).value;

  这个时候得到的     dt.Tables[0].Rows[0].SendTime     格式是:   Tue   May   15  
15:28:47

想明白   为什么会出现这种情况?
想显示成   2007-05-15   15:28:47   怎么办?

------解决方案--------------------
显示时间不挺简单的吗?
搞的那么负责作什么啊?

------解决方案--------------------
这个偶不懂,只能帮楼主顶了,同时学习中。
------解决方案--------------------
JS的日期字符本来就是这样的。如果你想显示成 2007-05-15 15:28:47的话,你就要写代码自己去拼接。
------解决方案--------------------
//日期时间类
Sys.DateTime = function(){
this.Value = new Date();

//解析一个字符串代表的时间
this.Parse = function(s){
var strs = s.split( " ");

if(strs.length < 2)return;

var sd = strs[0].split( "- ");
var st = strs[1].split( ": ");

this.SetYear(sd[0]);
this.SetMonth(sd[1]);
this.SetDate(sd[2]);
this.SetHours(st[0]);
this.SetMinutes(st[1]);
this.SetSeconds(st[2]);
}

//输出到字符串
this.ToString = function(){
var str = this.GetYear() + "- " + this.GetMonth() + "- " + this.GetDate();
return str + " " + this.GetHours() + ": " + this.GetMinutes()+ ": " + this.GetSeconds();
}

this.GetYear = function(){
return this.Value.getYear();
}

this.GetMonth = function(){
return this.Value.getMonth() + 1;
}

this.GetDate = function(){
return this.Value.getDate();
}

this.GetHours = function(){
return this.Value.getHours();
}

this.GetMinutes = function(){
return this.Value.getMinutes();
}

this.GetSeconds = function(){
return this.Value.getSeconds();
}

this.SetYear = function(v){
this.Value.setYear(v);
}

this.SetMonth = function(v){
this.Value.setMonth(parseInt(v) - 1);
}

this.SetDate = function(v){
this.Value.setDate(v);
}

this.SetHours = function(v){
this.Value.setHours(v);
}

this.SetMinutes = function(v){
this.Value.setMinutes(v);
}

this.SetSeconds = function(v){
this.Value.setSeconds(v);
}

return this;
}


Sys.DateTime SendTime = dt.Tables[0].Rows[0].SendTime;
SendTime.ToString();
------解决方案--------------------