Asp的日期怎么转化成习惯格式呀,高手来帮我

MyLearn 2003-08-19 04:57:31
var fso = Server.CreateObject('Scripting.FileSystemObject');
fsoFolder = fso.GetFolder(path);
FolderCredate = fsoFolder.DateCreated;
Response.Write(path + '---' + FolderCredate + '<br>' );

得到的结果是
d:\test\test3---Mon Aug 18 11:38:41 UTC+0800 2003

我想得到的效果是大家习惯格式,如
d:\test\test3---2003年8月18日11:38:41

请问如何得到,又没有转化的函数或方法。肯定给分
...全文
53 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
clicknet 2003-09-08
  • 打赏
  • 举报
回复
<%=formatdatetime(rs("start_time"),1)%>

后面常数值 描述
vbGeneralDate 0 显示日期和/或时间。如果有日期部分,则将该部分显示为短日期格式。如果有时间部分,则将该部分显示为长时间格式。如果都存在,则显示所有部分。
vbLongDate 1 使用计算机区域设置中指定的长日期格式显示日期。
vbShortDate 2 使用计算机区域设置中指定的短日期格式显示日期。
vbLongTime 3 使用计算机区域设置中指定的时间格式显示时间。
vbShortTime 4 使用 24 小时格式 (hh:mm) 显示时间。
GageCSDN 2003-08-19
  • 打赏
  • 举报
回复
怎么用Js呢,VBS中有FormatDateTime函数可以用。
用Js中的getFullYear()、getMonth()....函数吧,可以做到,麻烦一点。
sywj115447 2003-08-19
  • 打赏
  • 举报
回复
学习中。不过,要是在数据写入数据库时,就把当时的时间写入一个特定字段不就行了???
marry7 2003-08-19
  • 打赏
  • 举报
回复
UP
MyLearn 2003-08-19
  • 打赏
  • 举报
回复
楼上的用法好像不行,你是用了Date()对象,得到的是当前日期和时间,而我这个是利用fso的folder对象的DateLastAccessed属性,返回的是最后访问文件夹的日期和时间,如何将返回的结果转化成Date()对象呀
coffee_cn 2003-08-19
  • 打赏
  • 举报
回复
<%=year(now()) & "-"& right("0" & month(now()),2) & "-" & right("0" & day(now()),2)%>
把他改写成函数即可
zhuyangfeng 2003-08-19
  • 打赏
  • 举报
回复
刚才那个太烦了,这个简单:

<html>
<head>
<TITLE>背景时钟</TITLE>
<script language=javaScript runat=server>
<!--//
function clockon()
{
thistime= new Date()
var years=thistime.getYear()
var months=thistime.getMonth()+1
var days=thistime.getDate()
var hours=thistime.getHours()
var minutes=thistime.getMinutes()
var seconds=thistime.getSeconds()
if (eval(months) < 10) {months="0"+months}
if (eval(days) < 10) {days="0"+days}
if (hours < 10) {hours="0"+hours}
if (minutes < 10) {minutes="0"+minutes}
if (seconds < 10) {seconds="0"+seconds}
thistime = years+"年"+months+"月"+days+"日 "+hours+":"+minutes+":"+seconds
//thistime
if(document.all) {
bgclocknoshade.innerHTML=thistime
bgclockshade.innerHTML=thistime
}

if(document.layers) {
document.bgclockshade.document.write('<div id="bgclockshade" style="position:absolute;visibility:visible;font-family:Verdana;color:FFAAAA;font-size:120px;top:10px;left:152px">'+thistime+'</div>')
document.bgclocknoshade.document.write('<div id="bgclocknoshade" style="position:absolute;visibility:visible;font-family:Verdana;color:DDDDDD;font-size:120px;top:10px;left:150px">'+thistime+'</div>')
document.close()}

var timer=setTimeout("clockon()",1000)
}
//-->
</script>
</head>
<body onLoad="clockon()">
<div id="bgclockshade" style="position:absolute;visibility:visible;font-family:Arial;color:336699;font-size:30px;top:25px;left:38px"></div>
<div id="bgclocknoshade" style="position:visibility:visible;font-family:Arial;color:e0e0e0;font-size:100px;top:86px;left:125px"></div>
<div id="mainbody" style="position:absolute; visibility:visible">
</div>
<Dim MyDouble, MyByte
MyDouble = 125.5678
MyByte = CByte(MyDouble)>
<%=Rsponse.write"MyByte"%>

</body>
</html>

结果如下:
2003年08月19日 17:27:04
zhuyangfeng 2003-08-19
  • 打赏
  • 举报
回复


<%new date()
Function YmdList(yi,mi,di)
Dim y,m,d
'年
if yi="" or isnumeric(yi)=false then
y=year(now())
else
y=yi
end if

'月
if mi="" or isnumeric(mi)=false then
m=Month(now())
else
m=mi
end if
if m>13 then m=13
if m<1 then m=1

'日
if di="" or isnumeric(di)=false then
d=day(now())
else
d=di
end if
if m=2 and d>28 then
if y mod 4=0 then
if y mod 100=0 then
if y mod 1000=0 then
d=29
else
d=28
end if
else
d=29
end if
else
d=28
end if
end if
if (m=4 or m=6 or m=9 or m=11) and d>30 then d=30
if d<1 then d=1
YmdList=cstr(y)&"-"&cstr(m)&"-"&cstr(d)
End Function
%>

<%new date()
Function YmdHms(yi,mi,di,hi,msi,si)
dim h,ms,s

'时
if hi="" or isnumeric(hi)=false then
h=0
else
h=hi
end if
if h<0 then h=0
if h>=24 then h=23

'分
if msi="" or isnumeric(msi)=false then
ms=0
else
ms=msi
end if
if ms<0 then ms=0
if ms>=60 then ms=59

'秒
if si="" or isnumeric(si)=false then
s=0
else
s=si
end if
if s<0 then s=0
if s>=60 then s=59
YmdHms=YmdList(yi,mi,di)&" "&h&":"&ms&":"&s
End Function%>


<%'每月的天数
Function MonthDays(Yeari,Monthi)
Dim Days
Days=0
if Monthi=2 then
if Yeari mod 4=0 then
if Yeari mod 100=0 then
if Yeari mod 1000=0 then
Days=29
else
Days=28
end if
else
Days=29
end if
else
Days=28
end if
else
if Monthi=4 or Monthi=6 or Monthi=9 or Monthi=11 then
Days=30
else
Days=31
end if
end if
MonthDays=Days
End Function%>

<%'每天是星期几
Function DayWeek(Yeari,Monthi,Dayi)
Dim Days
Days=0
Dim yi,mi
'年
For yi=2001 to Yeari-1
if yi mod 4=0 then
if yi mod 100=0 then
if yi mod 1000=0 then
Days=Days+366
else
Days=Days+365
end if
else
Days=Days+366
end if
else
Days=Days+365
end if
Next
'月
For mi=1 to Monthi-1
Days=Days+MonthDays(Yeari,mi)
Next
Days=Days+Dayi
DayWeek=Days mod 7
End Function%>

<%'星期的中文表示方法
Function WeekName(wi)
Select case wi
case 0
WeekName="日"
case 1
WeekName="一"
case 2
WeekName="二"
case 3
WeekName="三"
case 4
WeekName="四"
case 5
WeekName="五"
case 6
WeekName="六"
End Select
WeekName="星期"&WeekName
End Function


function FirstDayOfWeek (nYear, nIndex)
dim dt, n
dt = dateserial(nYear, 1,1)
n = weekday(dt)
if n > 2 then
dt = dateadd("d", 7-n+2 , dt)
else
dt = dateadd("d", 2-n , dt)
end if

if nIndex > 1 then
dt = dateadd("d", 7*(nIndex-1) , dt)
end if
FirstDayOfWeek = dt
end function%>
<%response.write"&Ymdlist()&"%>
qwater 2003-08-19
  • 打赏
  • 举报
回复
FormatDateTime 函数
返回表达式,此表达式已被格式化为日期或时间。

FormatDateTime(Date[, NamedFormat])

参数
Date

必选项。要被格式化的日期表达式。

NamedFormat

可选项。指示所使用的日期/时间格式的数值,如果省略,则使用 vbGeneralDate。

设置
NamedFormat 参数可以有以下值:

常数 值 描述
vbGeneralDate 0 显示日期和/或时间。如果有日期部分,则将该部分显示为短日期格式。如果有时间部分,则将该部分显示为长时间格式。如果都存在,则显示所有部分。
vbLongDate 1 使用计算机区域设置中指定的长日期格式显示日期。
vbShortDate 2 使用计算机区域设置中指定的短日期格式显示日期。
vbLongTime 3 使用计算机区域设置中指定的时间格式显示时间。
vbShortTime 4 使用 24 小时格式 (hh:mm) 显示时间。

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧