当前位置:编程学习 > Delphi >>

delphi中,用 Label1.Caption:=DateTimetostr((now())); 读取的系统时间里面有:号,如何把冒号变为 _

如何把冒号变为下划线,然后再用label1显示?
答案:你可以用FormatDateTime,如:
Label1.Caption:=FormatDateTime('yyyy-mm-dd hh_nn_ss',now()); 
结果为:
xxxx-xx-xx xx_xx_xx

当然你可以这样写:
Label1.Caption := FormatDateTime('yyyy年mm月dd日 hh时nn分ss秒',now());
结果为:
xxxx年xx月xx日 xx时xx分xx秒
其他:Label1.Caption := StringReplace(DateTimetostr(now()),':','_',[rfReplaceAll]); 你可以用FormatDateTime('YYYY-MM-DD',Now) FormatDateTime('YYYY-MM-DD',Now) 

上一个:delphi ‘’=‘附近有语法错误
下一个:适合Delphi 制作大按键的软件皮肤制作工具?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,