vbs教程《日期时间》

来源:互联网 发布:深圳软件外包上市公司 编辑:程序博客网 时间:2024/05/16 10:09
dim curdate,curtime,curdatetimedim mydate,mytime,mydatetimerem 获取当前日期: 年/月/日curdate = date()rem 获取当前时间: 时:分:秒curtime = time()rem 获取现在时间: 年/月/日 时:分:秒curdatetime = now()rem 将有效数据转成时间类型mydate = cdate("2008/09/10")mytime = cdate("18:19:20")mydatetime = cdate("2009/10/11 19:20:21")rem 获取年rem msgbox(year(curdatetime))rem msgbox(year(curdate))rem msgbox(year(mydatetime))rem msgbox(year(mydate))rem msgbox(year("2017/11/12"))rem msgbox(year("2017/11"))rem msgbox(year("2018-10-20"))rem msgbox(year("2018-10"))rem 获取月(1~12)rem msgbox(month(curdatetime))rem msgbox(month(curdate))rem msgbox(month(mydatetime))rem msgbox(month(mydate))rem msgbox(month("2017/11/12"))rem msgbox(month("2017/11"))rem msgbox(month("11/12"))rem msgbox(month("2018-10-20"))rem msgbox(month("2018-10"))rem msgbox(month("10-20"))rem 获取日(1~31)rem msgbox(day(curdatetime))rem msgbox(day(curdate))rem msgbox(day(mydatetime))rem msgbox(day(mydate))rem msgbox(day("2017/11/12"))rem msgbox(day("11/12"))rem msgbox(day("2018-10-20"))rem msgbox(day("10-20"))rem 获取星期几(1~7) weekday(date,type[默认1从周日开始/2从周一开始])rem msgbox(weekday(curdatetime))rem msgbox(weekday(curdate))rem msgbox(weekday(mydatetime))rem msgbox(weekday(mydate))rem msgbox(weekday("2016/12/30"))rem 获取时(0~23)rem msgbox(hour(curdatetime))rem msgbox(hour(curtime))rem msgbox(hour(mydatetime))rem msgbox(hour(mytime))rem msgbox(hour("12:02:30"))rem msgbox(hour("12:02"))rem 获取分(0~59)rem msgbox(minute(curdatetime))rem msgbox(minute(curtime))rem msgbox(minute(mydatetime))rem msgbox(minute(mytime))rem msgbox(minute("12:02:30"))rem msgbox(minute("12:02"))rem 获取秒(0~59)rem msgbox(second(curdatetime))rem msgbox(second(curtime))rem msgbox(second(mydatetime))rem msgbox(second(mytime))rem msgbox(second("12:02:30"))

0 0
原创粉丝点击