关于Delphi时间加减有关问题,
关于Delphi时间加减问题,紧急求助啊
各位大哥,小弟有一问题需要紧急求助一下.
我有这样一个需求
我现在有Edit1里面显示为 2007-05-22 18:22:00 另外一个Edit2里有值35
我现在想用Button1把18:22:00的分钟加上35显示在Edit12007-05-22 18:57:00里.
这个时间应该怎么写,拜托各位大哥大姐帮帮啊.
小弟分不多,希望大家能帮帮啊
------解决方案--------------------
给个提示吧:
procedure TForm1.Button1Click(Sender: TObject);
var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
DecodeDate(Present, Year, Month, Day);
Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
+ IntToStr(Month) + ' of Year ' + IntToStr(Year);
DecodeTime(Present, Hour, Min, Sec, MSec);
Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
+ IntToStr(Hour);
end;
------解决方案--------------------
uses DateUtils;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit2.Text := FormatDateTime( 'YYYY-MM-DD HH:MM:SS ', IncMinute(StrToDateTime(Edit1.Text), 35));
end;
------解决方案--------------------
费了半天的劲,运行通过
edit1.Text:=formatdatetime( 'yyyy-MM-dd hh:mm:ss ',StrToDateTime(formatdatetime( 'yy-MM-dd hh:mm:ss ',now()))+35*60/(24*3600));
各位大哥,小弟有一问题需要紧急求助一下.
我有这样一个需求
我现在有Edit1里面显示为 2007-05-22 18:22:00 另外一个Edit2里有值35
我现在想用Button1把18:22:00的分钟加上35显示在Edit12007-05-22 18:57:00里.
这个时间应该怎么写,拜托各位大哥大姐帮帮啊.
小弟分不多,希望大家能帮帮啊
------解决方案--------------------
给个提示吧:
procedure TForm1.Button1Click(Sender: TObject);
var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
DecodeDate(Present, Year, Month, Day);
Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
+ IntToStr(Month) + ' of Year ' + IntToStr(Year);
DecodeTime(Present, Hour, Min, Sec, MSec);
Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
+ IntToStr(Hour);
end;
------解决方案--------------------
uses DateUtils;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit2.Text := FormatDateTime( 'YYYY-MM-DD HH:MM:SS ', IncMinute(StrToDateTime(Edit1.Text), 35));
end;
------解决方案--------------------
费了半天的劲,运行通过
edit1.Text:=formatdatetime( 'yyyy-MM-dd hh:mm:ss ',StrToDateTime(formatdatetime( 'yy-MM-dd hh:mm:ss ',now()))+35*60/(24*3600));