Deniz
Deniz

Reputation: 378

Clock cycle of time_t and getting time problem

I am trying to get current raw time (the one that is NOT human readable) in my simple while loop. I searched time_t clock cycle period but I couldn't find any information about it.

1st issue: Does anyone know the clock cycle period of time_t in C++?

2nd issue: When I print time ltime, it look same all the time.

time_t ltime;
while (count <= 1000) {
  time( & ltime); //I expect this to get current time in every cycle
  cout << "Current time " << ltime << endl;
  count++;
}

I already checked this link but it does not give information about clock period.

Upvotes: 0

Views: 132

Answers (1)

yumetodo
yumetodo

Reputation: 1202

Use std::chrono::high_resolution_clock::now()

Edit:

Use std::system_clock::now() and std::chrono::system_clock::to_time_t()

Upvotes: 1

Related Questions