📄 gettimeofday.2
字号:
.\" Copyright (c) 1980, 1991, 1993.\" The Regents of the University of California. All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\" notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\" notice, this list of conditions and the following disclaimer in the.\" documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\" must display the following acknowledgement:.\" This product includes software developed by the University of.\" California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\" may be used to endorse or promote products derived from this software.\" without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\" @(#)gettimeofday.2 8.1 (Berkeley) 6/4/93.\".Dd June 4, 1993.Dt GETTIMEOFDAY 2.Os BSD 4.Sh NAME.Nm gettimeofday ,.Nm settimeofday.Nd get/set date and time.Sh SYNOPSIS.Fd #include <sys/time.h>.Ft int.Fn gettimeofday "struct timeval *tp" "struct timezone *tzp".Ft int.Fn settimeofday "struct timeval *tp" "struct timezone *tzp".Sh DESCRIPTION.Bf -symbolicNote: timezone is no longer used; this information is kept outsidethe kernel..EfThe system's notion of the current Greenwich time and the current timezone is obtained with the.Fn gettimeofdaycall, and set with the.Fn settimeofdaycall. The time is expressed in seconds and microsecondssince midnight (0 hour), January 1, 1970. The resolution of the systemclock is hardware dependent, and the time may be updated continuously orin ``ticks.'' If.Fa tpor.Fa tzpis NULL, the associated timeinformation will not be returned or set..PpThe structures pointed to by.Fa tpand.Fa tzpare defined in .Ao Pa sys/time.h Acas:.Pp.Bd -literalstruct timeval { long tv_sec; /* seconds since Jan. 1, 1970 */ long tv_usec; /* and microseconds */};struct timezone { int tz_minuteswest; /* of Greenwich */ int tz_dsttime; /* type of dst correction to apply */};.Ed.PpThe .Fa timezonestructure indicates the local time zone(measured in minutes of time westward from Greenwich),and a flag that, if nonzero, indicates thatDaylight Saving time applies locally duringthe appropriate part of the year..PpOnly the super-user may set the time of day or time zone..Sh RETURNA 0 return value indicates that the call succeeded.A -1 return value indicates an error occurred, and in thiscase an error code is stored into the global variable.Va errno ..Sh ERRORSThe following error codes may be set in.Va errno :.Bl -tag -width [EFAULT].It Bq Er EFAULTAn argument address referenced invalid memory..It Bq Er EPERMA user other than the super-user attempted to set the time..El.Sh SEE ALSO.Xr date 1 ,.Xr adjtime 2 ,.Xr ctime 3 ,.Xr timed 8.Sh HISTORYThe.Nmfunction call appeared in.Bx 4.2 .
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -