SIMOrthoProgram-Orth_GF3-Strip/PSTM_simulation_windows2021.../PSTM_simulation_windows/common.cpp

31 lines
621 B
C++
Raw Normal View History

#include "common.h"
#include <time.h>
#include <chrono>
#include <ctime>
/**
* @brief GetCurrentTime
* @return
*/
std::string getCurrentTimeString() {
std::time_t t = std::time(NULL);
char mbstr[100];
std::strftime(mbstr, sizeof(mbstr), "%Y-%m-%d %H:%M:%S",
std::localtime(&t));
std::string strTime = mbstr;
return strTime;
}
std::string getCurrentShortTimeString() {
std::time_t t = std::time(NULL);
char mbstr[100];
std::strftime(mbstr, sizeof(mbstr), "%H:%M:%S",
std::localtime(&t));
std::string strTime = mbstr;
return strTime;
}