PlantCtrl/esp32/src/TimeUtils.cpp

18 lines
271 B
C++
Raw Normal View History

2021-07-01 21:19:51 +02:00
#include "TimeUtils.h"
#include <Homie.h>
long getCurrentTime()
{
struct timeval tv_now;
gettimeofday(&tv_now, NULL);
return tv_now.tv_sec;
}
int getCurrentHour()
{
struct tm info;
time_t now;
time(&now);
localtime_r(&now, &info);
return info.tm_hour;
}