javascript怎么由时间格式转换成C#中的string格式 Asp.net中:javascript怎么由时间格式转换成string格式 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ToString呗..能不能把你想要的说详细点?举个例子也行啊? 是这样的,我用VS把.Exl里面的数据读出来,exl里面的一列是时间格式的,转换的时候经常报错,有没有合适的办法让他不报错。 晕,你到底是要日期->字符串,还是字符串->时间如果日期->字符串就自己ToXXXXString就是了 晕倒,从.Exl里读出到js你不转的话怎么会是时间格式? 是这样,在exl里面,比如输入:2008-08-08,他就会自动转换成时间格式。我读的话就会出来很成一串格林时间。带GTS之类的。 js中将日期类型转换成字符串型格式(转)2008-06-22 12:13<script language="javascript">/////////////////////////////////e///////////////////////// 取得当前日期,格式yyyy-mm-dd////////////////////////////////////////////////////////function GetCurrentDate(){ var Year=0; var Month=0; var Day=0; var CurrentDate = new Date(); return ChangeDateToString(CurrentDate);}/////////////////////////////////e///////////////////////// 取得当前日期,格式yyyy-mm-dd hh:mm////////////////////////////////////////////////////////function GetCurrentTime(){ var Year=0; var Month=0; var Day=0; var CurrentDate = new Date(); return ChangeTimeToString(CurrentDate);}////////////////////////////////////////////////////////// 将日期类型转换成字符串型格式yyyy-MM-dd ////////////////////////////////////////////////////////function ChangeDateToString(DateIn){ var Year=0; var Month=0; var Day=0; var CurrentDate=""; //初始化时间 Year = DateIn.getYear(); Month = DateIn.getMonth()+1; Day = DateIn.getDate(); CurrentDate = Year + "-"; if (Month >= 10 ) { CurrentDate = CurrentDate + Month + "-"; } else { CurrentDate = CurrentDate + "0" + Month + "-"; } if (Day >= 10 ) { CurrentDate = CurrentDate + Day ; } else { CurrentDate = CurrentDate + "0" + Day ; } return CurrentDate;}///////////////////////////////////////////////////////// 将日期类型转换成字符串型格式yyyy-MM-dd hh:mm////////////////////////////////////////////////////////function ChangeTimeToString(DateIn){ var Year=0; var Month=0; var Day=0; var Hour = 0; var Minute = 0; var CurrentDate=""; //初始化时间 Year = DateIn.getYear(); Month = DateIn.getMonth()+1; Day = DateIn.getDate(); Hour = DateIn.getHours(); Minute = DateIn.getMinutes(); CurrentDate = Year + "-"; if (Month >= 10 ) { CurrentDate = CurrentDate + Month + "-"; } else { CurrentDate = CurrentDate + "0" + Month + "-"; } if (Day >= 10 ) { CurrentDate = CurrentDate + Day ; } else { CurrentDate = CurrentDate + "0" + Day ; } if(Hour >=10) { CurrentDate = CurrentDate + " " + Hour ; } else { CurrentDate = CurrentDate + " 0" + Hour ; } if(Minute >=10) { CurrentDate = CurrentDate + ":" + Minute ; } else { CurrentDate = CurrentDate + ":0" + Minute ; } return CurrentDate;}</script> 哪位高手解答下? 数据操作问题。checkboxlist绑定问题。取值问题。麻烦进来看下吧,急急。谢谢 用listview遍历我的C盘的文件啊 请问哪有ADO.NET 教程的下载地址?? 求援:DataSet真是害死人啊。用了他以后内存猛涨,大家帮忙看一下我的代码。谢谢!!! 【在没有任何数据时进行无效的读取尝试】在线等,马上结帐 求一循环算法?急用!!! WROX的站点配置??? 谁有学习ASP.NET的资料! 100分求救:asp.net 如何弹出新窗口? 给已知id的body增加div javascript 与表单提交
如果日期->字符串就自己ToXXXXString就是了
/////////////////////////////////e///////////////////////
// 取得当前日期,格式yyyy-mm-dd
////////////////////////////////////////////////////////
function GetCurrentDate()
{
var Year=0;
var Month=0;
var Day=0;
var CurrentDate = new Date(); return ChangeDateToString(CurrentDate);
}
/////////////////////////////////e///////////////////////
// 取得当前日期,格式yyyy-mm-dd hh:mm
////////////////////////////////////////////////////////
function GetCurrentTime()
{
var Year=0;
var Month=0;
var Day=0;
var CurrentDate = new Date(); return ChangeTimeToString(CurrentDate);
}
////////////////////////////////////////////////////////
// 将日期类型转换成字符串型格式yyyy-MM-dd
////////////////////////////////////////////////////////
function ChangeDateToString(DateIn)
{
var Year=0;
var Month=0;
var Day=0; var CurrentDate=""; //初始化时间
Year = DateIn.getYear();
Month = DateIn.getMonth()+1;
Day = DateIn.getDate();
CurrentDate = Year + "-";
if (Month >= 10 )
{
CurrentDate = CurrentDate + Month + "-";
}
else
{
CurrentDate = CurrentDate + "0" + Month + "-";
}
if (Day >= 10 )
{
CurrentDate = CurrentDate + Day ;
}
else
{
CurrentDate = CurrentDate + "0" + Day ;
}
return CurrentDate;
}///////////////////////////////////////////////////////
// 将日期类型转换成字符串型格式yyyy-MM-dd hh:mm
////////////////////////////////////////////////////////
function ChangeTimeToString(DateIn)
{
var Year=0;
var Month=0;
var Day=0;
var Hour = 0;
var Minute = 0;
var CurrentDate=""; //初始化时间
Year = DateIn.getYear();
Month = DateIn.getMonth()+1;
Day = DateIn.getDate();
Hour = DateIn.getHours();
Minute = DateIn.getMinutes();
CurrentDate = Year + "-";
if (Month >= 10 )
{
CurrentDate = CurrentDate + Month + "-";
}
else
{
CurrentDate = CurrentDate + "0" + Month + "-";
}
if (Day >= 10 )
{
CurrentDate = CurrentDate + Day ;
}
else
{
CurrentDate = CurrentDate + "0" + Day ;
}
if(Hour >=10)
{
CurrentDate = CurrentDate + " " + Hour ;
}
else
{
CurrentDate = CurrentDate + " 0" + Hour ;
}
if(Minute >=10)
{
CurrentDate = CurrentDate + ":" + Minute ;
}
else
{
CurrentDate = CurrentDate + ":0" + Minute ;
}
return CurrentDate;
}
</script>