📄 ctime.3
字号:
.\" Copyright (c) 1980 Regents of the University of California..\" All rights reserved. The Berkeley software License Agreement.\" specifies the terms and conditions for redistribution..\".\" @(#)ctime.3 6.8 (Berkeley) 4/2/87.\".TH CTIME 3 "April 2, 1987".UC 4.SH NAMEctime, localtime, gmtime, asctime, tzset \- convert date and time to ASCII.SH SYNOPSIS.nf.ft B#include <sys/types.h>#include <time.h>void tzset(void)char *ctime(const time_t *\fIclock\fP)char *asctime(const struct tm *\fItm\fP)struct tm *localtime(const time_t *\fIclock\fP)struct tm *gmtime(const time_t *\fIclock\fP).fi.SH DESCRIPTION\fBTzset\fP uses the value of the environment variable \fBTZ\fP toset up the time conversion information used by \fBlocaltime\fP..PPIf \fBTZ\fP does not appear in the environment, the \fBTZDEFAULT\fPfile (as defined in \fI<tzfile.h>\fP) is used by \fBlocaltime\fP. Ifthis file fails for any reason, the GMT offset as provided by thekernel is used. In this case, DST is ignored, resulting in the timebeing incorrect by some amount if DST is currently in effect. Ifthis fails for any reason, GMT is used..PPIf \fBTZ\fP appears in the environment but its value is a null string,Greenwich Mean Time is used; if \fBTZ\fP appears and begins with aslash, it is used as the absolute pathname of the \fBtzfile\fP(5)-formatfile from which to read the time conversion information; if \fBTZ\fPappears and begins with a character other than a slash, it's used asa pathname relative to the system time conversion information directory,defined as \fBTZDIR\fP in the include file \fBtzfile.h\fP. If this filefails for any reason, the GMT offset as provided by the kernel isused, as described above. If this fails for any reason, GMT is used.See.BR TZ (5)for a proper description of the.B TZvariable..PP\fBCtime\fP converts a time value, pointed to by \fIclock\fP,such as returned by \fBtime\fP(2) into ASCII and returns a pointerto a 26-character string in the following form. All the fieldshave constant width..PP.RS.nfSun Sep 16 01:03:52 1973\en\e0.fi.RE.PP.B Localtimeand.B gmtimereturn pointers to structures containingthe broken-down time..B Localtimecorrects for the time zone and possible daylight savings time;.B gmtimeconverts directly to GMT, which is the time UNIX uses..B Asctimeconverts a broken-down time to ASCII and returns a pointerto a 26-character string..PPThe structure declaration from the include file is:.PP.RS.nf.nr .0 .8i+\w'int tm_isdst'u.ta .5i \n(.0u \n(.0u+\w'/* 0-000'u+1nstruct tm { int tm_sec; /* 0-59 seconds */ int tm_min; /* 0-59 minutes */ int tm_hour; /* 0-23 hour */ int tm_mday; /* 1-31 day of month */ int tm_mon; /* 0-11 month */ int tm_year; /* 0- year \- 1900 */ int tm_wday; /* 0-6 day of week (Sunday = 0) */ int tm_yday; /* 0-365 day of year */ int tm_isdst; /* flag: daylight savings time in effect */ long tm_gmtoff; /* offset from GMT in seconds */ char **tm_zone; /* abbreviation of timezone name */};.fi.RE.PP\fBTm_isdst\fP is non-zero if a time zone adjustment such as DaylightSavings time is in effect..PP\fBTm_gmtoff\fP is the offset (in seconds) of the time representedfrom GMT, with positive values indicating East of Greenwich..SH FILES.ta \w'/usr/lib/zoneinfo\0\0'u/usr/lib/zoneinfo time zone information directory.br/etc/localtime local time zone file.SH SEE ALSO.BR time (2),.BR getenv (3),.BR tzfile (5),.BR TZ (5),.BR environ (7),.BR zic (8)..SH NOTEThe return values point to static data whose content is overwritten byeach call. The \fBtm_zone\fP field of a returned \fBstruct tm\fPpoints to a static array of characters, which will also be overwrittenat the next call (and by calls to \fBtzset\fP).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -