From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/chrono%2Ftime.html | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 devdocs/c/chrono%2Ftime.html (limited to 'devdocs/c/chrono%2Ftime.html') diff --git a/devdocs/c/chrono%2Ftime.html b/devdocs/c/chrono%2Ftime.html new file mode 100644 index 00000000..b7656af1 --- /dev/null +++ b/devdocs/c/chrono%2Ftime.html @@ -0,0 +1,40 @@ +

time

Defined in header <time.h>
time_t time( time_t *arg );
+

Returns the current calendar time encoded as a time_t object, and also stores it in the time_t object pointed to by arg (unless arg is a null pointer)

+

Parameters

+ +
arg - pointer to a time_t object where the time will be stored, or a null pointer

Return value

Current calendar time encoded as time_t object on success, (time_t)(-1) on error. If arg is not a null pointer, the return value is also stored in the object pointed to by arg.

+

Notes

The encoding of calendar time in time_t is unspecified, but most systems conform to POSIX specification and return a value of integral type holding the number of seconds since the Epoch. Implementations in which time_t is a 32-bit signed integer (many historical implementations) fail in the year 2038.

+

Example

#include <stdio.h>
+#include <time.h>
+#include <stdint.h>
+ 
+int main(void)
+{
+    time_t result = time(NULL);
+    if(result != (time_t)(-1))
+        printf("The current time is %s(%jd seconds since the Epoch)\n",
+               asctime(gmtime(&result)), (intmax_t)result);
+}

Possible output:

+
The current time is Fri Apr 24 15:05:25 2015
+(1429887925 seconds since the Epoch)

References

See also

+ + + +
+
(C23)(C11)
converts time since epoch to calendar time expressed as local time
(function)
+
(C23)(C11)
converts time since epoch to calendar time expressed as Coordinated Universal Time (UTC)
(function)
+
(C11)
returns the calendar time in seconds and nanoseconds based on a given time base
(function)
C++ documentation for time
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/chrono/time +

+
-- cgit v1.2.3