delphi中edit编辑框里面的值怎么取得电脑当前的日期和时间星期
3个回答
展开全部
要包含头文件:DateUtils
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DateUtils;
type
TForm1 = class(TForm)
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var s: string;
begin
case DayOfWeek(Today()) of
1: s := '星期日';
2: s := '星期一';
3: s := '星期二';
4: s := '星期三';
5: s := '星期四';
6: s := '星期五';
7: s := '星期六';
end;
Edit1.Text := DateTimeToStr(Now()) + ' '+ s;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DateUtils;
type
TForm1 = class(TForm)
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var s: string;
begin
case DayOfWeek(Today()) of
1: s := '星期日';
2: s := '星期一';
3: s := '星期二';
4: s := '星期三';
5: s := '星期四';
6: s := '星期五';
7: s := '星期六';
end;
Edit1.Text := DateTimeToStr(Now()) + ' '+ s;
end;
end.
展开全部
当前的日期和时间:Formatdatetime('YYYY-mm-DD HH:MM:SS',NOW)即可;
星期:
引用单元:SysUtils
function DayOfWeek(Date: TDateTime): Integer;
星期:
引用单元:SysUtils
function DayOfWeek(Date: TDateTime): Integer;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
procedure TForm1.Button1Click(Sender: TObject);
var
s : String;
begin
s := FormatDateTime('dddd',Now);
Edit1.Text := DateTimeToStr(Now())+ ' '+s;
end;
楼主望采纳
var
s : String;
begin
s := FormatDateTime('dddd',Now);
Edit1.Text := DateTimeToStr(Now())+ ' '+s;
end;
楼主望采纳
参考资料: 大仙
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询