1.. _posix-gettimeofday-sample:
2
3POSIX gettimeofday() with clock initialization over SNTP
4########################################################
5
6Overview
7********
8
9This sample application demonstrates using the POSIX gettimeofday()
10function to display the absolute wall clock time and local time every
11second. At system startup, the current time is queried using the SNTP
12networking protocol, enabled by setting the
13:kconfig:option:`CONFIG_NET_CONFIG_CLOCK_SNTP_INIT` and
14:kconfig:option:`CONFIG_NET_CONFIG_SNTP_INIT_SERVER` options.
15
16Requirements
17************
18
19- :ref:`networking_with_host`
20- or, a board with hardware networking
21- NAT/routing should be set up to allow connections to the Internet
22- DNS server should be available on the host to resolve domain names
23
24Building and Running
25********************
26
27This project outputs to the console.  It can be built and executed
28on QEMU as follows:
29
30.. zephyr-app-commands::
31   :zephyr-app: samples/posix/gettimeofday
32   :host-os: unix
33   :board: qemu_x86
34   :goals: run
35   :compact:
36
37For comparison, a version for native POSIX operating systems (e.g. Linux)
38can be built using:
39
40.. code-block:: console
41
42   make -f Makefile.posix
43