Skip to content

Instantly share code, notes, and snippets.

@niftycode
Created August 24, 2016 14:41
Show Gist options
  • Save niftycode/2eb64123dcdca7a8b4f3969e73493a8d to your computer and use it in GitHub Desktop.
Save niftycode/2eb64123dcdca7a8b4f3969e73493a8d to your computer and use it in GitHub Desktop.
Convert the UNIX time to a human readable string
/* EpochConverter */
#include <iostream>
#include <time.h>
using namespace std;
int main(int argc, const char * argv[]) {
int inputTime;
struct tm *timeinfo;
// Enter epoch time
cout << "Epoch time: " << endl;
cin >> inputTime;
time_t rawtime = inputTime;
timeinfo = localtime(&rawtime);
printf("%s\n", asctime(timeinfo));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment