程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> MonthOfTheYear、WeekOfTheYear、WeekOfTheMonth、DayOfTheYear.

MonthOfTheYear、WeekOfTheYear、WeekOfTheMonth、DayOfTheYear.

編輯:Delphi

SysUtils.DayOfWeek();
DateUtils.MonthOfTheYear();
DateUtils.WeekOfTheYear();
DateUtils.WeekOfTheMonth();
DateUtils.NthDayOfWeek();
DateUtils.DayOfTheYear();
DateUtils.DayOfTheMonth();
DateUtils.DayOfTheWeek();
DateUtils.SysUtils.DayOfWeek();
DateUtils.HourOfTheYear();
DateUtils.HourOfTheMonth();
DateUtils.HourOfTheWeek();
DateUtils.HourOfTheDay();
DateUtils.MinuteOfTheYear();
DateUtils.MinuteOfTheMonth();
DateUtils.MinuteOfTheWeek();
DateUtils.MinuteOfTheDay();
DateUtils.MinuteOfTheHour();
DateUtils.SecondOfTheYear();
DateUtils.SecondOfTheMonth();
DateUtils.SecondOfTheWeek();
DateUtils.SecondOfTheDay();
DateUtils.SecondOfTheHour();
DateUtils.SecondOfTheMinute();
DateUtils.MilliSecondOfTheYear();
DateUtils.MilliSecondOfTheMonth();
DateUtils.MilliSecondOfTheWeek();
DateUtils.MilliSecondOfTheDay();
DateUtils.MilliSecondOfTheHour();
DateUtils.MilliSecondOfTheMinute();
DateUtils.MilliSecondOfTheSecond();

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
t: TDateTime;
w: Word;
c: Cardinal;
i: Int64;
begin
t := StrToDateTime('2009-5-20 11:22:33');
{指定時間是年度第幾月份}
w := MonthOfTheYear(t); //5
{指定時間分別是年、月的第幾周}
w := WeekOfTheYear(t); //21
w := WeekOfTheMonth(t); //3
w := NthDayOfWeek(t); //3
{指定時間分別是年、月、周的第幾天}
w := DayOfTheYear(t); //140
w := DayOfTheMonth(t); //20
w := DayOfTheWeek(t); //3
w := SysUtils.DayOfWeek(t); //4; DayOfWeek 和 DayOfTheWeek 類似, 但算法不同
{指定時間分別是年、月、周、日的第幾小時}
w := HourOfTheYear(t); //3347
w := HourOfTheMonth(t); //467
w := HourOfTheWeek(t); //59
w := HourOfTheDay(t); //11
{指定時間分別是年、月、周、日、時的第幾分鐘}
c := MinuteOfTheYear(t); //200842
w := MinuteOfTheMonth(t); //28042
w := MinuteOfTheWeek(t); //3562
w := MinuteOfTheDay(t); //682
w := MinuteOfTheHour(t); //22
{指定時間分別是年、月、周、日、時、分的第幾秒}
c := SecondOfTheYear(t); //12050553
c := SecondOfTheMonth(t); //1682553
c := SecondOfTheWeek(t); //213753
c := SecondOfTheDay(t); //40953
w := SecondOfTheHour(t); //1353
w := SecondOfTheMinute(t); //33
{指定時間分別是年、月、周、日、時、分、秒的第幾毫秒}
i := MilliSecondOfTheYear(t); //12050553000
c := MilliSecondOfTheMonth(t); //1682553000
c := MilliSecondOfTheWeek(t); //213753000
c := MilliSecondOfTheDay(t); //40953000
c := MilliSecondOfTheHour(t); //1353000
c := MilliSecondOfTheMinute(t); //33000
w := MilliSecondOfTheSecond(t); //0
end;
end.
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved