Operating systems, development tools, and professional services
for connected embedded systems
for connected embedded systems
![]() |
![]() |
![]() |
![]() |
settimeofday()
Set the time and date
Synopsis:
#include <sys/time.h>
int settimeofday( const struct timeval *when,
void *not_used );
Arguments:
- when
- A pointer to a timeval structure that specifies the
the time that you want to set.
The struct timeval contains the following members:
- long tv_sec -- the number of seconds since the start of the Unix Epoch.
- long tv_usec -- the number of microseconds.
- not_used
- This pointer must be NULL or the behavior of settimeofday() is unspecified. This argument is provided only for backwards compatibility.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
This function sets the time and date to the values stored in the structure pointed to by when.
Returns:
0, or -1 if an error occurred (errno is set).
Errors:
- EFAULT
- An error occurred while accessing the when buffer.
- EPERM
- The calling process doesn't have superuser permissions.
Classification:
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |
Caveats:
The settimeofday() function is provided for compatibility with existing Unix code. You shouldn't use it in new code -- use clock_settime() instead.
See also:
asctime(), asctime_r(), clock_gettime(), clock_settime(), ctime(), ctime_r(), difftime(), gettimeofday(), gmtime(), gmtime_r(), localtime(), localtime_r(), time()
![]() |
![]() |
![]() |
![]() |

![[Previous]](../prev.gif)
![[Contents]](../contents.gif)
![[Index]](../keyword_index.gif)
![[Next]](../next.gif)