mydomain

C语言中格式化日期时间ctime()函数

函数原型:char *ctime(const time_t *time);

功能说明:time_t类型日期和时间转换为字符串。

返回值:返回由tm结构中的日期和时间转换成的字符串的地址,该字符串的形式定义如下:

DDD MMM dd hh:mm:ss YYYY

各字符的意义:

DDD   一星期的某一天Mon

MMM  月份,Jan

dd     月中一天(1,2,……,31

hh     小时(1,2,……,24

mm    分钟(1,2,……,59

ss      秒数(1,2,……,59

YYYY 

范例: 将当前的时间与日期转换为字符串输出。

#include

#include

int main()

{

time_t t;

time(&t);

printf("%s\n", ctime(&t));

return 0;

}

原文

http://www.eefocus.com/xuefu2009/blog/10-04/188679_b2f1a.html

分类:

技术点:

相关文章:

  • 2021-05-19
  • 2021-08-23
  • 2022-12-23
猜你喜欢
  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
  • 2021-06-11
  • 2022-02-10
  • 2022-12-23
  • 2021-10-02
相关资源
相似解决方案