将当前时间格式为YYYYMMDDHHMMSS格式
发布时间:2007-3-20 15:57:48
原理重点:把月日时分秒不为两位数的前面补零
function dtos(num)
'dtos函数是把单位数变成双位数,即在单位数前面补0
dtos=cstr(num)
if len(dtos)<2 then
dtos="0"&dtos
else
dtos=dtos
end if
dtos=cint(dtos)
end function
function day_date()
'day_date函数是把当前日期的年月日时分秒按格式联接
day_month=dtos(month(now))
day_day=dtos(day(now))
day_hour=dtos(hour(now))
day_minute=dtos(minute(now))
day_second=dtos(second(now))
day_date=cstr(year(now))&cstr(day_month)&cstr(day_day)&cstr(day_day)&cstr(day_hour)&cstr(day_minute)&cstr(day_second)
end function
注:如果不是格式当前时间的话,把day_date()函数作如下更改:
function day_date(ydm)
'day_date函数是把当前日期的年月日时分秒按格式联接,参数ydm必须为正确的时间格式
day_month=dtos(month(ydm))
day_day=dtos(day(ydm))
day_hour=dtos(hour(ydm))
day_minute=dtos(minute(ydm))
day_second=dtos(second(ydm))
day_date=cstr(year(ydm))&cstr(day_month)&cstr(day_day)&cstr(day_day)&cstr(day_hour)&cstr(day_minute)&cstr(day_second)
end function