gpt4 book ai didi

delphi - 将 int 变量格式化为 mm :ss

转载 作者:行者123 更新时间:2023-12-03 14:55:03 28 4
gpt4 key购买 nike

谁能帮我如何将delphi中的int变量格式化为分钟:秒?

样本:myVar := 19;

我的标签标题应显示 00:19

有人知道吗?谢谢

最佳答案

这将避免秒值溢出到小时中的任何错误。

var
secs: integer;
str: string;
begin
secs := 236;
// SecsPerDay comes from the SysUtils unit.
str := FormatDateTime('nn:ss', secs / SecsPerDay));

// If you need hours, too, just add "hh:" to the formatting string
secs := 32236;
str := FormatDateTime('hh:nn:ss', secs / SecsPerDay));
end;

关于delphi - 将 int 变量格式化为 mm :ss,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9175021/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com