您的位置:首页 > 运维架构 > Linux

linux下用来修改系统时间的函数

2006-09-09 18:09 393 查看
 Standard C Library Functions                     gettimeofday(3C)

NAME
     gettimeofday, settimeofday - get or set the date and time

SYNOPSIS
     #include <sys/time.h>

#include <unistd.h>

 

     int gettimeofday(struct timeval *tp, void *);

     int settimeofday(struct timeval *tp, void *);

DESCRIPTION
     The gettimeofday()  function  gets  and  the  settimeofday()
     function  sets  the system's notion of the current time. The
     current  time  is   expressed   in   elapsed   seconds   and
     microseconds since 00:00 Universal Coordinated Time, January
     1, 1970. The resolution of  the  system  clock  is  hardware
     dependent;  the time may be updated continuously or in clock
     ticks.

     The  tp  argument  points  to  a  timeval  structure,  which
     includes the following members:

     long    tv_sec;    /* seconds since Jan. 1, 1970 */
     long    tv_usec;   /* and microseconds */

     If tp is a null pointer, the current time information is not
     returned or set.

     The TZ environment variable holds time zone information. See
     TIMEZONE(4).

     The second argument  to  gettimeofday()  and  settimeofday()
     should be a pointer to NULL.

     Only the super-user may set the time of day.

RETURN VALUES
     Upon successful completion, 0 is returned.  Otherwise, -1 is
     returned and errno is set to indicate the error.

 

settimeofday(const struct timeval * t , const struct timezone *tzv )
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息