strftime与strptime比较系统时间与输入字符串时间

#include <stdio.h>
#include <time.h>

int main ()
{
	struct tm tm_time;  
        strptime("2013-04-24 18:38:00", "%Y-%m-%d %H:%M:%S", &tm_time);   
	
	struct tm *p;
	char buffer [20];
	time_t timep;
	time(&timep);
	p=localtime(&timep);
	strftime (buffer, 20, "%Y-%m-%d %H:%M", p);
	printf("current time: %s\n", buffer);

	if (mktime(p) < mktime(&tm_time))
		printf("ok,%ld,%ld\n",mktime(p),mktime(&tm_time));
	else
		printf("error,%ld,%ld\n",mktime(p),mktime(&tm_time));

  	return 0;
}

你可能感兴趣的:(strftime与strptime比较系统时间与输入字符串时间)