zoukankan      html  css  js  c++  java
  • YearsBetween、MonthsBetween ... YearSpan、MonthSpan ... 间隔时间

    DateUtils.YearsBetween();
    DateUtils.MonthsBetween();
    DateUtils.WeeksBetween();
    DateUtils.DaysBetween();
    DateUtils.HoursBetween();
    DateUtils.MinutesBetween();
    DateUtils.SecondsBetween();
    DateUtils.MilliSecondsBetween();
    
    DateUtils.YearSpan();
    DateUtils.MonthSpan();
    DateUtils.WeekSpan();
    DateUtils.DaySpan();
    DateUtils.HourSpan();
    DateUtils.MinuteSpan();
    DateUtils.SecondSpan();
    DateUtils.MilliSecondSpan();
    

    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
      t1,t2: TDateTime;
      i: Int64;
      d: Double;
    begin
      t1 := StrToDateTime('2009-5-20 11:22:33');
      t2 := StrToDateTime('2020-9-21 22:33:44');
    
      i := YearsBetween(t1, t2);        //11
      i := MonthsBetween(t1, t2);       //136
      i := WeeksBetween(t1, t2);        //591
      i := DaysBetween(t1, t2);         //4142
      i := HoursBetween(t1, t2);        //99419
      i := MinutesBetween(t1, t2);      //5965151
      i := SecondsBetween(t1, t2);      //357909071
      i := MilliSecondsBetween(t1, t2); //357909070999
    
      i := YearsBetween(t2, t1);        //11, 参数无先后
    
      {下面这个系列返回的时间间隔是 Double 类型的, 更精确}
      d := YearSpan(t1, t2);        //11.3414540712855
      d := MonthSpan(t1, t2);       //136.097448855426
      d := WeekSpan(t1, t2);        //591.780871362434
      d := DaySpan(t1, t2);         //4142.46609953704
      d := HourSpan(t1, t2);        //99419.1863888889
      d := MinuteSpan(t1, t2);      //5965151.18333333
      d := SecondSpan(t1, t2);      //357909071
      d := MilliSecondSpan(t1, t2); //357909071000
    end;
    
    end.
    


    DateUtils-Function
  • 相关阅读:
    MySQL(一)
    HTML基础
    python函数基础
    常用的模块
    面向对象进阶
    定制自己的数据类型
    Shell篇之AWK
    MATLAB如何实现傅里叶变换FFT?有何物理意义?
    傅里叶分析
    2018年度关键词
  • 原文地址:https://www.cnblogs.com/del/p/1467513.html
Copyright © 2011-2022 走看看