Delphi中如何使用FormatDateTime函数进行日期时间格式化?

2026-06-09 08:361阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计596个文字,预计阅读时间需要3分钟。

Delphi中如何使用FormatDateTime函数进行日期时间格式化?

cfunction FormatDateTime(Format: string; DateTime: TDateTime): string;Format参数是一个格式化字符串。DateTime是一个时间类型。返回值是格式化后的字符串。主要看Format参数中的指令字符+c。

function FormatDateTime(const Format: string; DateTime: TDateTime): string;

Format参数是一个格式化字符串。DateTime是时间类型。返回值是一种格式化后的字符串,重点来看Format参数中的指令字符

 

c以短时间格式显示时间,即全部是数字的表示 FormatdateTime('c',now); 输出为:2004-8-7 9:55:40

d 对应于时间中的日期,日期是一位则显示一位,两位则显示两位 FormatdateTime('d',now); 输出可能为1~31

 

dd 和d的意义一样,但它始终是以两位来显示的 FormatdateTime('dd',now); 输出可能为01~31

ddd 显示的是星期几 FormatdateTime('ddd',now); 输出为: 星期六

 

Delphi中如何使用FormatDateTime函数进行日期时间格式化?

dddd 和ddd显示的是一样的。 但上面两个如果在其他国家可能不一样。

阅读全文

本文共计596个文字,预计阅读时间需要3分钟。

Delphi中如何使用FormatDateTime函数进行日期时间格式化?

cfunction FormatDateTime(Format: string; DateTime: TDateTime): string;Format参数是一个格式化字符串。DateTime是一个时间类型。返回值是格式化后的字符串。主要看Format参数中的指令字符+c。

function FormatDateTime(const Format: string; DateTime: TDateTime): string;

Format参数是一个格式化字符串。DateTime是时间类型。返回值是一种格式化后的字符串,重点来看Format参数中的指令字符

 

c以短时间格式显示时间,即全部是数字的表示 FormatdateTime('c',now); 输出为:2004-8-7 9:55:40

d 对应于时间中的日期,日期是一位则显示一位,两位则显示两位 FormatdateTime('d',now); 输出可能为1~31

 

dd 和d的意义一样,但它始终是以两位来显示的 FormatdateTime('dd',now); 输出可能为01~31

ddd 显示的是星期几 FormatdateTime('ddd',now); 输出为: 星期六

 

Delphi中如何使用FormatDateTime函数进行日期时间格式化?

dddd 和ddd显示的是一样的。 但上面两个如果在其他国家可能不一样。

阅读全文