环境:
SunOS solaris 5.10 Generic_139556-08 i86pc i386 i86pc
Thread model: posix
gcc version 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
man帮助说明是:
%C Century number (the year divided by 100 and trun-
cated to an integer as a decimal number [01,99]).
目的:需要格式20090101.
例子:
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> main() { time_t t; time ( &t ); char machine_date[17]; t = time(0); cftime(machine_date,"%C%y%d%m",&t);
//cftime(machine_date,"%Y%d%m",&t); printf("[%s]\n",machine_date); }
|
%C输出:
[Wed May 27 17:38:10 CST 2009092705]
%Y才是需要的:
[20072705]
阅读(2071) | 评论(0) | 转发(0) |