Ejemplo n.º 1
0
static void PrintDateTimeWithMilliSeconds(void)
{
    const system_clock::time_point now = system_clock::now();
    system_clock::duration tp = now.time_since_epoch();
    tp -= duration_cast<seconds>(tp);
    const time_t tt = system_clock::to_time_t(now);
    const tm t = *localtime(&tt);
    printf("%04u-%02u-%02u %02u:%02u:%02u.%03u",
                t.tm_year + 1900,
                t.tm_mon + 1,
                t.tm_mday, 
                t.tm_hour, 
                t.tm_min, 
                t.tm_sec,
                static_cast<unsigned>(tp/ milliseconds(1)));
}
Ejemplo n.º 2
0
long long getTimeInMs(system_clock::time_point &point) {
	auto millitime = std::chrono::duration_cast<milliseconds>(point.time_since_epoch()).count();
	return millitime;
}
Ejemplo n.º 3
0
 std::time_t system_clock::to_time_t(const system_clock::time_point& t)
 {
     return static_cast<std::time_t>( t.time_since_epoch().count() / 1000000000 );
 }