ASP关于时间的一些处理~

<%
ntime =  now()
ndate = date()
nweek = Weekday(ndate)
shijian=cstr(year(ntime))+right("0"+cstr(month(ntime)),2)+right("0"+cstr(day(ntime)),2)+right("0"+cstr(hour(ntime)),2)+right("0"+cstr(minute(ntime)),2)

response.Write ntime & "<br>" & vbCRLF
response.Write ndate & "<br>" & vbCRLF
response.Write shijian & "<br>" & vbCRLF
response.Write year(ntime)&"年"&month(ntime)&"月"&day(ntime)&"日"& "<br>" & vbCRLF

function week(d)
if d=2 then '为星期一
m=6
n=0
elseif d=3 then '为星期二
m=5
n=1
elseif d=4 then '为星期三
m=4
n=2
elseif d=5 then '为星期四
m=3
n=3
elseif d=6 then '为星期五
m=2
n=4
elseif d=7 then '为星期六
m=1
n=5
elseif d=1 then '为星期日
m=0
n=6
end if
response.Write(year(date()-n)&"."&month(date()-n)&"."&day(date()-n)&"---"&month(date()+m)&"."&day(date()+m))
end function

response.Write "本周日期为:"&week(weekday(date()))& "<br>" & vbCRLF

d=date()
response.write "今天是:" & d & "<br>" & vbCRLF
w=datepart("w",d)-1
if w=0 then w=7
response.write "今天是周:" & w & "<br>" & vbCRLF
n=w-1
a=w-2
b=w-3
c=w-4
e=w-5
m=w-6
s=w-7
response.write "本周一是:" & dateadd("d",-n,d)& "<br>" & vbCRLF
response.write "本周二是:" & dateadd("d",-a,d)& "<br>" & vbCRLF
response.write "本周三是:" & dateadd("d",-b,d)& "<br>" & vbCRLF
response.write "本周四是:" & dateadd("d",-c,d)& "<br>" & vbCRLF
response.write "本周五是:" & dateadd("d",-e,d)& "<br>" & vbCRLF
response.write "本周六是:" & dateadd("d",-m,d)& "<br>" & vbCRLF
response.write "本周日是:" & dateadd("d",-s,d)& "<br>" & vbCRLF
%>

 

上面的显示结果为:

2010-6-13 18:30:58
2010-6-13
201006131830
2010年6月13日
2010.6.7---6.13本周日期为:
今天是:2010-6-13
今天是周:7
本周一是:2010-6-7
本周二是:2010-6-8
本周三是:2010-6-9
本周四是:2010-6-10
本周五是:2010-6-11
本周六是:2010-6-12
本周日是:2010-6-13

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值