软件教程

asp时间转化为数字、字符串方法

来源: 本站    类别: 软件教程    日期: 2012/3/6

 

asp中我想取时间如2009-8-4 16:03:04中数字,但用cstr函数或别的转化后都是2009841634,请问怎样才能使其变为“200984160304”?也就是时间中数字小于10时也显示两位。

  <%

  str=now

  str=replace(str," ","")

  str=replace(str,"-","")

  str=replace(str,":","")

  str=replace(str,"上午","")

  str=replace(str,"下午","")

  response.write str

  %>

  '***************************************************

  '函 数 名:getYYYYMMDDHHIISS

  '作    用:根据给定的日期和时间型数据将其转换为YYYYMMDDHHIISS字符串格式

  '参    数:d 日期型数据,t 时间型数据

  '返 回 值:转换后的字符串

  '***************************************************

  Function GetYYYYMMDDHHIISS(d,t)

  YYYY=Year(d)

  MM=Month(d)

  DD=Day(d)

  HH=Hour(t)

  II=Minute(t)

  SS=Second(t)

  If Len(YYYY) =2 then

  YYYY="20" & YYYY

  End If

  If Len(MM)=1 then

  MM="0" & MM

  End If

  If Len(DD)=1 then

  DD="0" & DD

  End If

  If Len(HH)=1 then

  HH="0" & HH

  End If

  If Len(II)=1 then

  II="0" & II

  End If

  If Len(SS)=1 then

  SS="0" & SS

  End If

  GetYYYYMMDDHHIISS=YYYY & MM & DD & HH & II & SS

  End Function


相关文章


Copyright © 2004 - 2024 CNHWW Inc. All Rights Reserved
石家庄市征红网络科技有限公司版权所有 邮政编码:050051
服务电话:0311-85315152 13931185013 在线客服QQ:81447932 / 81447933 邮箱: cnhww@163.com