delphi RecodeDateTime、RecodeDate、RecodeTime、RecodeYear ... 修改时间


本文整理自网络,侵删。

 RecodeDateTime、RecodeDate、RecodeTime、RecodeYear ... 修改时间
DateUtils.RecodeDateTime();
DateUtils.RecodeDate();
DateUtils.RecodeTime();
DateUtils.RecodeYear();
DateUtils.RecodeMonth();
DateUtils.RecodeDay();
DateUtils.RecodeHour();
DateUtils.RecodeMinute();
DateUtils.RecodeSecond();
DateUtils.RecodeMilliSecond();
DateUtils.TryRecodeDateTime();
--------------------------------------------------------------------------------


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);
const
st = 'yyyy-m-d h:n:s:z';
var
t1, t2: TDateTime;
begin
t1 := EncodeDateTime(2001, 1, 1, 1, 1, 1, 1);

t2 := RecodeDateTime(t1, 2009, 5, 21, 11, 22, 33, 999);
ShowMessage(FormatDateTime(st, t2)); //2009-5-21 11:22:33:999

t2 := RecodeDate(t1, 2009, 5, 21);
ShowMessage(FormatDateTime(st, t2)); //2009-5-21 1:1:1:1

t2 := RecodeTime(t1, 11, 22, 33, 999);
ShowMessage(FormatDateTime(st, t2)); //2009-1-1 11:22:33:999

t2 := RecodeYear(t1, 2009);
ShowMessage(FormatDateTime(st, t2)); //2009-1-1 1:1:1:1

t2 := RecodeMonth(t1, 5);
ShowMessage(FormatDateTime(st, t2)); //2001-5-1 1:1:1:1

t2 := RecodeDay(t1, 21);
ShowMessage(FormatDateTime(st, t2)); //2001-1-21 1:1:1:1

t2 := RecodeHour(t1, 11);
ShowMessage(FormatDateTime(st, t2)); //2001-1-1 11:1:1:1

t2 := RecodeMinute(t1, 22);
ShowMessage(FormatDateTime(st, t2)); //2001-1-1 1:22:1:1

t2 := RecodeSecond(t1, 33);
ShowMessage(FormatDateTime(st, t2)); //2001-1-1 1:1:33:1

t2 := RecodeMilliSecond(t1, 999);
ShowMessage(FormatDateTime(st, t2)); //2001-1-1 1:1:1:999

if TryRecodeDateTime(t1, 2009, 5, 21, 11, 22, 33, 999, t2) then
ShowMessage(FormatDateTime(st, t2)); //2009-5-21 11:22:33:999
end;

end.

相关阅读 >>

汇编基础知识

Delphi 声明指令

Delphi xe android-uri-管理联系人uri

Delphi 收集了比较全的字符串进制转换

Delphi代码变异加密工具

Delphi 获取文件大小根据显示gb mb kb b

Delphi 2009 之 tstringbuilder 类[5]: chars[] 属性与 copyto 方法

Delphi 相对路径和绝对路径的转换

Delphi自动以管理员身份在vista 和 windows7 下运行程序

Delphi stringgrid 实例5 本例功能:字体修改为居中,红色,20号

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



打赏

取消

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

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

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

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

评论

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