O'Reilly logo

Getting Started With JUCE by Martin Robinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Measuring and displaying time

The JUCE Time class provides a cross-platform way to specify, measure, and format date and time information in a human-readable fashion. Internally, the Time class stores a value in milliseconds relative to midnight on 1st January 1970. To create a Time object that represents the current time, use Time::getCurrentTime() like the following:

Time now = Time::getCurrentTime();

To bypass the creation of the Time object, you can access the millisecond counter as a 64-bit value directly:

int64 now = Time::currentTimeMillis();

The Time class also provides access to a 32-bit millisecond counter that measures time since system startup:

uint32 now = Time::getMillisecondCounter();

The important point to note about Time::getMillisecondCounter() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required