6常用日期与时间函数

6常用日期与时间函数

ID:37581003

大小:789.50 KB

页数:42页

时间:2019-05-25

6常用日期与时间函数_第1页
6常用日期与时间函数_第2页
6常用日期与时间函数_第3页
6常用日期与时间函数_第4页
6常用日期与时间函数_第5页
资源描述:

《6常用日期与时间函数》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、Delphi6常用日期与时间函数D.1获取特定的日期与时间本小节将为您介绍Delphi6所提供的获取特定日期与时间的函数。这些函数稍后将有详细的范例说明。笔者这里将以列表的方式先说明每一个函数所代表的意义,如图示:函数名称单元文件所代表的意义NowSysUtils此函数可返回现在的日期与时间,其返回值为TDateTime类型DateSysUtils此函数可返回现在的日期,其返回值为TDateTime类型TimeSysUtils此函数可返回现在的时间,其返回值为TDateTime类型TodayDateUtils此函数可返回今天的日期,其返回值为TDateT

2、ime类型,此函数的结果与Date函数相同。TomorrowDateUtils此函数可返回昨天的日期,其返回值为TDateTime类型YesterdayDateUtils此函数可返回明天的日期,其返回值为TDateTime类型CurrentyearSysUtils此函数可返回现在所属的年度,其返回值为4的整数。例如:2001HoursperdaySysUtils此常数定义每天的小时数。HoursPerDay=24;MinsperdaySysUtils此常数定义每天的分钟数。MinsPerDay=MinsPerDay*60SecsperdaySysUtil

3、s此常数定义每天的秒数。SecPerDay=MinsPerDay*60msecsperdaySysUtils此常数定义每天的毫秒数。MSecsPerDay=SecsperDay*1000Now(返回当前的日期时间)引用单元:SysUtils函数声明:FunctionNow:TDateTime;范例D-1ProcedureTForm1.Button1Click(Sender:TObject);VarMyDateTime:TDateTime;beginMyDateTime:=Now;Showmessage(DateTimeToStr(MyDateTime))

4、;end;Date(返回当前的日期)引用单元:SysUtils函数声明:FunctionDay:TDateTime;范例D-2ProcedureTForm1.Button1Click(Sender:TObject);VarMyDateTime:TDateTime;beginMyDateTime:=Date;Showmessage(DateTimeToStr(MyDateTime));end;Time(返回当前的时间)引用单元:SysUtils第42页(共42页)函数声明:FunctionTime:TDateTime;范例D-3ProcedureTForm

5、1.Button1Click(Sender:TObject);VarMyDateTime:TDateTime;beginMyDateTime:=Time;Showmessage(DateTimeToStr(MyDateTime));end;Today(返回今天的日期)引用单元:DateUtils函数声明:FunctionToday:TDateTime;范例D-4ProcedureTForm1.Button1Click(Sender:TObject);VarMyDateTime:TDateTime;Begin//usesDateUtilsMyDateTim

6、e:=Today;Showmessage(DateTimeToStr(MyDateTime));end;Tomorrow(返回明天的日期)引用单元:DateUtils函数声明:FunctionTomorrow:TDateTime;范例D-5ProcedureTForm1.Button1Click(Sender:TObject);VarMyDateTime:TDateTime;Begin//usesDateUtilsMyDateTime:=Tomorrow;//MyDateTime:Now+1;//两者相同Showmessage(DateTimeToStr

7、(MyDateTime));//不包含时间部分end;Yesterday(返回昨天的日期)引用单元:DateUtils函数声明:FunctionYesterday:TDateTime;范例D-6ProcedureTForm1.Button1Click(Sender:TObject);VarMyDateTime:TDateTime;第42页(共42页)Begin//usesDateUtilsMyDateTime:=Yesterday;//MyDateTime:Now-1;//两者相同Showmessage(DateTimeToStr(MyDateTime)

8、);//不包含时间部分end;CurrentYear(返回现在所属的年度)引用单

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。