Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ get time

#include <chrono>

// Get the time since epoch (realtime clock), in milliseconds
int64_t getCurrentMSinceEpoch()
{
	return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
}

// Get the time since started, in milliseconds
// Better for time difference because it's faster than system_clock
int64_t getTimeMS()
{
	return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #time
ADD COMMENT
Topic
Name
8+4 =