Fandom

Delphi Programming

HourOf Routine/Example 1

< HourOf Routine

2,918pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

unit Unit1; 

interface

 uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 
  Dialogs;
 

type
 TForm1 = class(TForm)
 
   procedure FormCreate(Sender: TObject);
 
 end;


 var  
  Form1: TForm1;


 implementation 

{$R *.dfm} 

uses 
  DateUtils;
 
procedure TForm1.FormCreate(Sender: TObject); 
var 
  dt, d, t: TDateTime;
 
  Year, Month, Week, Day, Hour, Minute, Second, MilliSecond: Word;

 begin
  dt := StrToDateTime('2009-5-20 11:22:33');
 
  d := DateOf(dt); 
  ShowMessage(DateToStr(d)); //2009-5-20 
  
  t := TimeOf(dt); 
  ShowMessage(TimeToStr(t)); //11:22:33
  
  Year        := YearOf(dt); 
  Month       := MonthOf(dt); 
  Week        := WeekOf(dt); 
  Day         := DayOf(dt); 
  Hour        := HourOf(dt); 
  Minute      := MinuteOf(dt); 
  Second      := SecondOf(dt); 
  MilliSecond := MilliSecondOf(dt);
  ShowMessageFmt('%d,%d,%d,%d,%d,%d,%d,%d', [Year,Month,Week,Day,Hour,Minute, 
    Second,MilliSecond]); {2009,5,20,11,22,33,0}
 end; 

end.

Also on Fandom

Random Wiki