关于时间函数

2016-02-19 13:21 3 1 收藏

只要你有一台电脑或者手机,都能关注图老师为大家精心推荐的关于时间函数,手机电脑控们准备好了吗?一起看过来吧!

【 tulaoshi.com - 编程语言 】

  在工程文件中Application.Run语句之前加入下面语句,可不让主Form在运行时显示:
        Application.ShowMainForm := False;

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  显示设置时间的对话框
     ShellExecute(Handle, 'open', 'control', 'date/time', nil, SW_SHOW);

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  FormatDateTime('yyyy mmmm',MyDate) 返回如

  //获得日期  Date := Trunc( DateTime );
       //获得时间  Time := Frac( DateTime );

  计算任意月份的天数
      procedure TForm1.Button10Click(Sender: TObject);
        function DaysInMonth(ADate:TDateTime):Integer;
        var MyYear,MyMonth,MyDay : Word;
          MyDayTable : TDayTable;
          tmpBool : Boolean;
        begin
          DecodeDate(ADate, MyYear, MyMonth, MyDay);
          tmpBool := IsLeapYear(MyYear);
          MyDayTable := MonthDays[tmpBool];
          Result := MyDayTable[MyMonth];
        end;

      var MyDate : TDateTime; tmpStr : String;  tmpInt : Integer;
      begin
        MyDate := strToDateTime('2003-12-01');
        tmpStr := FormatDateTime('yyyy mmmm',MyDate);
        tmpInt := DaysInMonth(MyDate);
        ShowMessage(tmpStr + ' 有 ' + IntToStr(tmpInt) + 'ìì');
      end;

  
  改变系统时间
  1、定义变量
  var SystemTime: TSystemTime;
  2、转换日期
  DateTimeToSystemTime(StrToDatetime('1999-09-01 11:12:12' ),SystemTime);
  3、改变系统日期
  SetSystemTime(SystemTime);
  到此系统日期已经改变,可是由于API函数SetSystemTime()本身存在的BUG,
  在你改变系统日期以后,等待一会,你会看到系统的日期是对的,可是时间却错了,
  并不是我们设定的11:12:12,这样的问题看来需要微软才能解决了

  /////////////////////       方法二           /////////////////////////
  { SetDate sets the current date in the operating system. Valid  }
  { parameter ranges are: Year 1980-2099, Month 1-12 and Day      }
  { 1-31. If the date is not valid, the function call is ignored. }
  procedure SetDate(Year, Month, Day: Word); assembler;
  asm
   MOV CX,Year
   MOV DH,BYTE PTR Month
   MOV DL,BYTE PTR Day
   MOV AH,2BH
   INT 21H
  end;

  { SetTime sets the time in the operating system. Valid          }
  { parameter ranges are: Hour 0-23, Minute 0-59, Second 0-59 and }
  { Sec100 (hundredths of seconds) 0-99. If the time is not       }
  { valid, the function call is ignored.                          }
  procedure SetTime(Hour, Minute, Second, Sec100: Word); assembler;
  asm
   MOV CH,BYTE PTR Hour
   MOV CL,BYTE PTR Minute
   MOV DH,BYTE PTR Second
   MOV DL,BYTE PTR Sec100
   MOV AH,2DH
   INT 21H
  end;

  function SetSystemDateTime(Year, Month, Day, Hour, Minute, Second: word): integer;   export;
  begin
    SetDate(Year, Month, Day);
    SetTime(Hour, Minute + 1, Second, 0);
    result := 1;
  end;
  

来源:https://www.tulaoshi.com/n/20160219/1603941.html

延伸阅读
标签: Web开发
% ''''''''''''''''断剑注释''''''''''''''''''''''''' ''''strText为要切取内容的那段打的内容'''''''''''' ''''strStarTag为要切取内容的开始的地方'''''''''' ''''strEndTag为要切取内容的结束的地方'''''''''' ''''GetText返回值为切取出来的内容'''''''''''''' '''''''''''''''注释结束'''''''''''''''''''''''' Function GetText(strText...
标签: excel
excel2010中的时间函数运用   我们经常在使用Excel的时候,会用到许多的函数。如果你不会使用函数,那就证明你还是个Excel表格的新手。俗话说得好,不会使用Excel函数,你永远都不能被称为一个办公软件的高手。但还是有很多的用户对Excel函数十分陌生。今天为大家介绍一下时间函数。 DATE函数 选中单元格,然后在输入框中输...
标签: ASP
  MonthName 函数 描述:返回表明指定月份的字符串。 语法:MonthName(month[, abbreviate]) month: 必选。月份的数值定义。例如,一月是 1,二月是 2,以此类推。 abbreviate: 可选。Boolean 值,表明月份名称是否简写。如果省略,默认值为 False,即不简写月份名称。 Now 函数 描述:根据计算机系统设定的日期和时间返回当前的日期和时...
标签: ASP
  DateSerial 函数 描述:对于指定的年、月、日,返回 Date 子类型的 Variant。 语法:DateSerial(year, month, day) year: 从 100 到 9999 之间的数字或数值表达式。 month: 任意数值表达式。 day: 任意数值表达式。 说明:要指定日期,如 1991 年 12 月 31 日,DateSerial 函数中每个参数的取值范围都应该是可接受的;即日的取值应在 1 ...
标签: 孕前
关于受孕时间的黄金数字 因此,请记住以下这些有关的数字,它们是: 较好受孕时间:11月至次年1月。即避开宝宝在寒冬或醋暑时节诞生。 容易受孕时间:下次月经前14天或两次月经中间的4--5天内,即排卵期及排卵前2--3天至排卵期后的1--2天。 早孕反应出现时间:一般受孕后40天左右开始。 首次...

经验教程

166

收藏

43
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部