The C language implements the character Fu Jing Unix timestamp, which needs to be converted to a TM type before getting its Unix timestamp. Attached implementation code:
#include <stdio.h>
#include <time.h>
int strtotime (char datetime[])
{
struct TM tm_time;
int unixtime;
Strptime (DateTime, "%y-%m-%d%h:%m:%s", &tm_time);
Unixtime = Mktime (&tm_time);
return unixtime;
}
Attach a few time related functions, make a note:
//Current time
char* get_curr_time ()
{
char* strtime = (char *) malloc (sizeof (char) * );
memset (strtime, 0, sizeof (char) *20);
time_t now;
Time (&now);
Strftime (Strtime, "%y-%m-%d%h:%m:%s", Gmtime (&now));
printf ("Info:current time%s\n", strtime);
return strtime;
}
The current time's UNIX timestamp
int get_curr_unixtime (void)
{
time_t now;
int unixtime = time (&now);
return unixtime;
}
Character to Unix time stamp
int strtotime (char datetime[])
{
struct TM tm_time;
int unixtime;
Strptime (DateTime, "%y-%m-%d%h:%m:%s", &tm_time);
Unixtime = Mktime (&tm_time);
return unixtime;
}
Above the C language implementation of the word Fu Jing Unix Timestamp Simple example is a small series to share all the content, hope to give you a reference, but also hope that we support cloud habitat community.