随笔分类 - Time
摘要:#include<iostream>using namespace std;int main(){ int year,month,day; int m[12]={31,28, 31,30,31,30,31,31,30,31,30,31}; cout<<"请输入年月日:"; cin>>year>>month>>day; if(year%400==0 || year%4==0 && year%100!=0) m[1]=29; int sumdays=0; for(int i=0;i<month-1
阅读全文
摘要:bool IsToday(time_t nLastTime, time_t nNowTime){time_t LastTime = nLastTime;struct tm localTime;localtime_r(&LastTime, &localTime);time_t NowTime = nNowTime;struct tm localNowTime;localtime_r(&NowTime, &localNowTime);if (localTime.tm_year == localNowTime.tm_year &&localTime.t
阅读全文
摘要:#include <stdio.h>#include <time.h>#include <iostream>using namespace std;int main(void){time_t timep;struct tm *p;time(&timep);printf("time() : %d \n",timep);p=localtime(&timep);timep = mktime(p);printf("time()->localtime()->mktime():%d\n",timep);
阅读全文
摘要:#include <iostream>#include <time.h>using namespace std;int main() {char szBeginTime[32] ={0};time_t tmBeginTime = time(NULL);struct tm *tmNowBegin = localtime(&tmBeginTime);strftime(szBeginTime,32,"%Y-%m-%d %H:%M:%S",tmNowBegin);fprintf(stderr, "Connect Begin Time %s\
阅读全文
摘要:#include<iostream>#include<ctime>using namespace std;int main(){time_t now_time;now_time = time(NULL);cout<<now_time;getchar();return 0;}
阅读全文