Delphi 时间操作函数
DateUtils.StartOfTheMonth(Now) //本月第一天 DateUtils.EndOfTheMonth(Now) //本月最后一天 DateUtils.YearsBetween() DateUtils.MonthsBetween() DateUtils.DaysBetween(); DateUtils.HoursBetween(); DateUtils.MinutesBetween(); DateUtils.SecondsBetween(); DateUtils.MilliSecondsBetween() DateUtils.IncYear(); DateUtils.IncMonth(); DateUtils.IncWeek(); DateUtils.IncDay(); DateUtils.IncHour(); DateUtils.IncMinute(); DateUtils.IncSecond(); DateUtils.IncMilliSecond(); //两个时间差是否在 xx 个年、月,周,天,小时,分钟,秒,毫秒内 DateUtils.WithinPastYears(); DateUtils.WithinPastMonths(); DateUtils.WithinPastWeek(); DateUtils.WithinPastDays(); DateUtils.WithinPastHours(); DateUtils.WithinPastMinutes(); DateUtils.WithinPastSeconds(); DateUtils.WithinPastMilliSeconds();
procedure TForm1.FormCreate(Sender: TObject); var t1,t2: TDateTime; b: Boolean; begin t1 := StrToDateTime('2009-5-20 11:22:33'); t2 := StrToDateTime('2009-5-21 11:22:33'); {两个时间差是否在 24 年内} b := WithinPastYears(t1, t2, 24); //True {两个时间差是否在 24 个月内} b := WithinPastMonths(t1, t2, 24); //True {两个时间差是否在 24 个周内} b := WithinPastWeeks(t1, t2, 24); //True {两个时间差是否在 24 天内} b := WithinPastDays(t1, t2, 24); //True {两个时间差是否在 24 个小时内} b := WithinPastHours(t1, t2, 24); //True {两个时间差是否在 24 分钟内} b := WithinPastMinutes(t1, t2, 24); //False {两个时间差是否在 24 秒内} b := WithinPastSeconds(t1, t2, 24); //False {两个时间差是否在 24 毫秒内} b := WithinPastMilliSeconds(t1, t2, 24); //False // ShowMessage(BoolToStr(b, True)); end;
本文来自博客园,作者:IT情深,转载请注明原文链接:https://www.cnblogs.com/wh445306/p/16751675.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)