/* ctime example */
#include <stdio.h>
#include <time.h>
#include <iostream>
using namespace std;
int main ()
{
time_t rawtime;
time ( &rawtime );
printf("%ld\n", &rawtime);
printf ( "The current local time is: %s", ctime (&rawtime) );
char * time = ctime(&rawtime);
//ctime(&rawtime) : time_t/timestampe -> "Www Mmm dd hh:mm:ss yyyy" format
cout<< time << endl;
printf("%s", asctime(gmtime(&rawtime)));// asctime(gmtime(&rawtime)) = ctime(&rawtime);
//here gmtime(&rawtime) : time_t(timpstampe) -> struct tm
//here asctime(gmtime) : struct tm -> "Www Mmm dd hh:mm:ss yyyy" format
struct tm * ptm;
ptm = gmtime(&rawtime);
cout<<(ptm->tm_year + 1900)<<"year "<<(ptm->tm_mon + 1)<<"month "<<(ptm->tm_mday)<<"day "<<(ptm
->tm_hour)<<":"<<(ptm->tm_min)<<":"<<(ptm->tm_sec)<<endl;
return 0;
}