Last active
December 11, 2015 22:39
-
-
Save adrianmoses/4671337 to your computer and use it in GitHub Desktop.
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 <time.h> | |
| #define TIME_SIZE 100 | |
| char * getcurrenttime(){ | |
| char *buffer = malloc(TIME_SIZE); | |
| struct tm *ts; | |
| size_t size; | |
| time_t timestamp = time(NULL); | |
| ts = localtime(×tamp); | |
| size = strftime(buffer, 32, "%a, %d %b %Y %T %z", ts); | |
| buffer[size] = '\0'; | |
| return buffer; | |
| } | |
| int main(void){ | |
| char *current_time = getcurrenttime(); | |
| printf("%s\n", current_time); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment