【C++】获取系统时间
2013-10-11 16:27
253 查看
DateTimeData::DateTimeData() { m_strDate = ""; m_longDate = 0l; time_t t = time(0); char temp[64]; m_longDate = t; strftime(temp, sizeof(temp), "%Y-%m-%d %H:%M:%S", localtime(&t)); m_strDate = temp; } DateTimeData::DateTimeData(string strDate) { if (strDate == "" || strDate.length() != 19) { m_longDate = 0l; m_strDate = ""; return; } m_strDate = strDate; tm t; t.tm_year = atoi(m_strDate.substr(0,4).c_str()); t.tm_mon = atoi(m_strDate.substr(5,7).c_str()) - 1; t.tm_mday = atoi(m_strDate.substr(8,10).c_str()); t.tm_hour = atoi(m_strDate.substr(11,13).c_str()); t.tm_min = atoi(m_strDate.substr(14,16).c_str()); t.tm_sec = atoi(m_strDate.substr(17,19).c_str()); t.tm_isdst = 0; time_t t_ = mktime(&t); m_longDate = t_; }
相关文章推荐
- C/C++中获取系统时间
- C\C++时间处理函数[获取系统时间,求时间差,格式化输出等]
- C++获取系统时间
- c++获取当前系统时间并输出到文件中
- c/c++获取系统时间
- c++ 如何获取系统时间
- Window系统下C/C++程序毫秒级和微秒级执行时间获取方法
- C/C++获取当前系统时间
- C++获取系统时间
- Cocos2d-x中用C++获取当前系统时间,实现跨平台
- C/C++获取当前系统时间
- C++ linux获取系统时间
- C++获取当前系统时间的方法(转载)
- 获取系统时间(C++)
- 获取系统当前时间C/C++
- 操作系统大型实验进展(4)-----C/C++如何获取系统时间
- C/C++获取当前系统时间
- C/C++获取当前系统毫秒时间 .
- C/C++获取当前系统时间
- 如何利用C++的time头文件获取系统时间