Created
November 21, 2019 16:31
-
-
Save fernandoc1/95c4ef81486199613b2b575991fccc39 to your computer and use it in GitHub Desktop.
This code prints the local time in Linux with a C program.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <time.h> | |
| #include <stdint.h> | |
| int main() | |
| { | |
| time_t currentTime = time(NULL); | |
| struct tm* localTime = localtime(¤tTime); | |
| char dateStr[100]; | |
| sprintf(dateStr, "%s/%04d_%02d_%02d_%02d_%02d_%02d.h264", | |
| "Date is: ", | |
| localTime->tm_year + 1900, | |
| localTime->tm_mon + 1, | |
| localTime->tm_mday, | |
| localTime->tm_hour, | |
| localTime->tm_min, | |
| localTime->tm_sec | |
| ); | |
| printf("%s\n", dateStr); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment