RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
SysUtils.Now Function

Returns the current date and time.

Pascal
function Now: TDateTime;
C++
TDateTime Now();

SysUtils

Returns the current date and time, corresponding to the sum of the value returned by the global Date and Time functions.

Note: Although TDateTime values can represent milliseconds, Now is accurate only to the nearest second.
 

C++ Examples: 

 

/*
This example uses a label and a button on a form. When the
user clicks the button, the current date and time is
converted to a string and displayed as the caption of the
label:
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  Label1->Caption = DateTimeToStr(Now());
}

 

Delphi Examples: 

{
This example uses a label and a button on a form. When the
user clicks the button, the current date and time is
converted to a string and displayed as the caption of the
label:
} 
procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption := SysUtils.DateTimeToStr(Now);
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!