Getting current timestamp or tracking duration of keypress

Hi,

is there a cross-platform way in cocos2d-x to get the current timestamp?

What I really want to do is track how long the user has performed a certain action, for example how long they have held down a key.

Thanks for the help

using namespace std;
using namespace chrono;

double _dCurrentTime = duration(system_clock::now().time_since_epoch()).count();

  • #include
    at the top