28 lines
476 B
C++
28 lines
476 B
C++
#pragma once
|
|
|
|
#include <ctime>
|
|
#include <cstring>
|
|
#include <string>
|
|
|
|
class Htime
|
|
{
|
|
time_t tv;
|
|
|
|
public:
|
|
Htime() {}
|
|
|
|
std::string get_local_time_now()
|
|
{
|
|
static char buffer[128];
|
|
|
|
struct tm *_local_time = nullptr;
|
|
|
|
memset(buffer, 0x0, sizeof(buffer));
|
|
|
|
tv = time(nullptr);
|
|
_local_time = localtime(&tv);
|
|
strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", _local_time);
|
|
|
|
return std::string(buffer);
|
|
}
|
|
}; |