delphi IncYear、IncMonth、IncWeek、IncDay、IncHour、IncMinute、IncSecond、IncMilliSecond �C 增时


本文整理自网络,侵删。

 

DateUtils.IncYear();
DateUtils.IncMonth();
DateUtils.IncWeek();
DateUtils.IncDay();
DateUtils.IncHour();
DateUtils.IncMinute();
DateUtils.IncSecond();
DateUtils.IncMilliSecond();

  unit Unit1;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, StdCtrls;type  TForm1 = class(TForm)    procedure FormCreate(Sender: TObject);  end;var  Form1: TForm1;implementation{$R *.dfm}uses DateUtils;procedure TForm1.FormCreate(Sender: TObject);var  t1,t2: TDateTime;  i: Int64;  d: Double;begin  t1 := StrToDateTime('2011-1-1 1:1:1');  t2 := IncYear(t1);  ShowMessage(DateTimeToStr(t2)); //2012-1-1 1:01:01  t2 := IncYear(t1, 3);  ShowMessage(DateTimeToStr(t2)); //2014-1-1 1:01:01  t2 := IncMonth(t1);  ShowMessage(DateTimeToStr(t2)); //2011-2-1 1:01:01  t2 := IncWeek(t1);  ShowMessage(DateTimeToStr(t2)); //2011-1-8 1:01:01  t2 := IncDay(t1);  ShowMessage(DateTimeToStr(t2)); //2011-1-2 1:01:01  t2 := IncHour(t1);  ShowMessage(DateTimeToStr(t2)); //2011-1-1 2:01:01  t2 := IncMinute(t1);  ShowMessage(DateTimeToStr(t2)); //2011-1-1 1:02:01  t2 := IncSecond(t1);  ShowMessage(DateTimeToStr(t2)); //2011-1-1 1:01:02  t2 := IncMilliSecond(t1);  ShowMessage(FormatDateTime('yyyy-m-d h:n:s:zzz', t2)); //2011-1-1 1:01:01:001end;end.

相关阅读 >>

Delphi datasnap 的http 调用返回json

Delphi 字符串插入与删除

Delphi 将字符串转换成 utf8 编码的函数

Delphi 将整数转换为罗马数字(字符串)2

Delphi 链接获取主站地址

Delphi中强制idhttp使用http1.1

Delphi7 写过卡巴主动防御服务端

winapi 字符及字符串函数(8): ischarupper - 是否是个大写字母

Delphi 程序启动窗体控制在桌面右下角

Delphi xe7 rest获取天气实例

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...