其他分享
首页 > 其他分享> > IncYear、IncMonth、IncWeek、IncDay、IncHour、IncMinute、IncSecond、IncMilliSecond - 增时

IncYear、IncMonth、IncWeek、IncDay、IncHour、IncMinute、IncSecond、IncMilliSecond - 增时

作者:互联网

IncYear、IncMonth、IncWeek、IncDay、IncHour、IncMinute、IncSecond、IncMilliSecond - 增时

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

unit Unit1;

interface

uses
  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:001
end;

end.


DateUtils-Function
posted on 2009-05-20 16:48  万一  阅读(12429)  评论(0)  编辑  收藏

标签:IncYear,DateUtils,01,IncSecond,t2,t1,IncDay,DateTimeToStr,ShowMessage
来源: https://blog.51cto.com/u_14617575/2748113