Last active
January 2, 2016 13:49
-
-
Save jxq0/8313041 to your computer and use it in GitHub Desktop.
c++ date trans
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
time_t StrToStamp(const string &str, const string &fmt) | |
{ | |
struct tm tmInfo; | |
strptime(str.c_str(), fmt.c_str(), &tmInfo); | |
return mktime(&tmInfo); | |
} | |
int TransDateStr(const string &src, const string &fmt_src, string &dst, const string &fmt_dst) | |
{ | |
struct tm tmInfo; | |
strptime(src.c_str(), fmt_src.c_str(), &tmInfo); | |
char buff[32]; | |
strftime(buff, 32, fmt_dst.c_str(), &tmInfo); | |
dst = string(buff); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment