In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how C++ under linux to achieve the conversion between string and time_t related knowledge, the content is detailed and easy to understand, easy to operate, with a certain reference value, I believe that after reading this string under linux C++ how to achieve conversion between string and time_t article will have a harvest, let's take a look at it.
The code is as follows:
# include # include # include using namespace std;time_t string2time_t (const string string_time); string time_t2string (const time_t time_t_time); int main () {string strTime = "18:25:26 on 2014-03-28"; time_t time1 = string2time_t (strTime); couttm_sec); string strTime = szTime; delete pTm; pTm = NULL; return strTime;} string get_time () {string timeStr / / time_t t = time (0); time_t t = time (NULL); char tmp [64]; strftime (tmp, sizeof (tmp), "% Y-%m-%d% X", localtime (& t)); / / 2017-05-16 17:00:00 timeStr = tmp; return timeStr } time_t convert_string_to_time_t (const std::string & time_string) {struct tm tm1; time_t time1 Sscanf (time_string.c_str (), "% d-%d-%d% d:%d:%d", & (tm1.tm_year), & (tm1.tm_mon), & (tm1.tm_mday) & (tm1.tm_hour), & (tm1.tm_min), & (tm1.tm_sec) Tm1.tm_year-= 1900; tm1.tm_mon--; tm1.tm_isdst=-1; time1 = mktime (& tm1); return time1;} this is the end of the article on "how C++ converts string and time_t under linux". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how C++ realizes the conversion between string and time_t under linux". If you want to learn more knowledge, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.