
本文共 2974 字,大约阅读时间需要 9 分钟。
������������������������������������strptime���strftime���������������
������������������������������������������������������������������������C������������time.h
������������������������������������������������������������������������������������������������������������������������������strftime
���strptime
���localtime
���mktime
���gmtime
���������������������������������������������������������������
strptime���strftime������
strftime
������������������������������tm
���������������������������������������������������������������������������������������������������������������������������������������������strftime
������������������
#include#include #include using namespace std;int main() { time_t rawtime; struct tm *timeinfo; char buffer[80]; time(&rawtime); timeinfo = localtime(&rawtime); int length = strftime(buffer, 80, "%Y-%m-%dT%H:%M:%SZ\n", timeinfo); printf("timestamp: %.*s", length, buffer); return 0;}
������������������strftime
������������������"YYYY-MM-DDTHH:MM:SZ"
���������������������������
���������strptime
���������������������������������������������������������tm
���������������strftime
������������������������������������������������������������������������������"2001-11-12 18:31:01"
���������������������
#include#include #include #include using namespace std;int main() { struct tm *timeinfo; char buffer[80]; memset(timeinfo, 0, sizeof(struct tm)); if (strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", timeinfo) != -1) { int length = strftime(buffer, 80, "%Y-%m-%dT%H:%M:%SZ\n", timeinfo); printf("timestamp: %.*s", length, buffer); } exit(EXIT_SUCCESS);}
localtime���mktime������
localtime
���������time_t
���������������������������������tm
������������mktime
������������������tm
���������������time_t
���������������������������������������������������������������������������������mktime
������������tm
������������������������������������
������������������������������������������localtime
���������������������
#include#include using namespace std;int main() { time_t rawtime; struct tm *timeinfo; time(&rawtime); timeinfo = localtime(&rawtime); printf("���������������%TM\n", timeinfo); return 0;}
���������������������������������UTC���������������������������������������gmtime
��������������������� UTC���������������tm
���������
������
������������������������������������������������������������������������������������������������������������������������
time(0)
���clock()
������������������strftime
���strptime
���������������������������������������������������tm
���������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
