Skip to content

Instantly share code, notes, and snippets.

@chuckremes
Created February 11, 2017 23:11
Show Gist options
  • Save chuckremes/698b0ee5d1279374cb1ef3add82a6f18 to your computer and use it in GitHub Desktop.
Save chuckremes/698b0ee5d1279374cb1ef3add82a6f18 to your computer and use it in GitHub Desktop.
#include <time.h>
#include <string.h>
#include <errno.h>
#define LOGGER_TIME_SIZE 16
int main() {
time_t clock;
struct tm lt;
char formatted_time_[LOGGER_TIME_SIZE];
time(&clock);
localtime_r(&clock, &lt);
strftime(formatted_time_, LOGGER_TIME_SIZE, "%b %e %H:%M:%S", &lt);
return errno; // returns EINVAL, 22 which is set by strftime
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment