ctime64_r()- 将时间转换为字符串 (可重新启动)
格式
#include <time.h>
char *ctime64_r(const time64_t *time, char *buf);语言级别
ILE C 扩展
线程安全
是
语言环境敏感
此函数的行为可能受当前语言环境的 LC_TOD 类别影响。 有关更多信息,请参阅 了解 CCSID 和语言环境。
描述
此函数是 ctime64() 函数的可重新启动版本。
ctime64() 函数将 time 指向的时间值以字符串形式转换为本地时间。 通常通过调用 time64() 函数来获取 time 值。
ctime64_r() 函数生成的字符串结果正好包含 26 个字符,并且具有以下格式: "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n"例如: Mon Jul 16 02:03:55 1987\n\0ctime64_r() 函数使用 24 小时制的时钟格式。 使用的月份和日期缩写是从语言环境中检索的。 所有字段都具有恒定宽度。 只有 1 个数字的日期前面有一个零。 换行符 (\n) 和空字符 (\0) 占据字符串的最后两个位置。
返回值
ctime64_r() 函数返回一个指向字符串结果的指针。 如果该函数不成功,那么它将返回 NULL。 对 ctime64_r() 函数的调用等效于: asctime_r(localtime64_r(&anytime, buf2), buf)示例
此示例使用
time64()轮询系统时钟。 然后打印一条消息,给出当前的日期和时间。#include <time.h>
#include <stdio.h>
int main(void)
{
time64_t ltime;
char buf[50];
time64(<ime);
printf("the time is %s", ctime64_r(<ime, buf));
}
相关信息
- asctime ()-将时间转换为字符串
- asctime_r ()-将时间转换为字符串 (可重新启动)
- ctime ()-将时间转换为字符串
- ctime64()-将时间转换为字符串
- ctime_r ()-将时间转换为字符串 (可重新启动)
- gmtime ()-转换时间
- gmtime64()-转换时间
- gmtime64_r()-转换时间 (可重新启动)
- gmtime_r ()-转换时间 (可重新启动)
- localtime ()-转换时间
- localtime64()-转换时间
- localtime64_r()-转换时间 (可重新启动)
- localtime_r ()-转换时间 (可重新启动)
- mktime ()-转换本地时间
- mktime64()-转换本地时间
- strftime ()-将日期/时间转换为字符串
- time ()-确定当前时间
- time64()-确定当前时间
- <time.h>