获取当前日期和时间ctime()

ctime()函数是C语言中的时间处理函数,它将时间戳转换为人类可读的日期和时间字符串。该函数需要包含<time.h>头文件。ctime()返回一个结构体tm,包含了秒、分钟、小时、日期、月份、年份等信息,并且以'年-1900年'的形式表示年份。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ctime() -将秒转换成日期和时间

头文件

#include <time.h>

函数

   char * asctime(const struct tm * tm ); 
   char * asctime_r(const struct tm * tm ,char * buf );

   char * ctime(const time_t * timep ); 
   char * ctime_r(const time_t * timep ,char * buf );

   struct tm * gmtime(const time_t * timep ); 
   struct tm * gmtime_r(const time_t * timep ,struct tm * result );

   struct tm * localtime(const time_t * timep ); 
   struct tm * localtime_r(const time_t * timep ,struct tm * result );

   time_t mktime(struct tm * tm );

struct tm {
int tm_sec; / 秒(0-60) /
int tm_min; / 分钟(0-59) /
int tm_hour; / 小时(0-23) /
int tm_mday; /

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值