[solved]Time of day in milliseconds using QDateTime::toMSecsSinceEpoch();



  • Hi!

    I need to know the time of day in milliseconds.
    Basically the value of a counter, that starts every day at 0ms and ends at 86400000ms.

    My idea is simple enough:
    Take the present QDateTime::toMSecsSinceEpoch(); timestamp and subtract the timestamp from tonight at 00:00:00,000... but how do I get the MSecsSinceEpoch of a certain point in the past?

    There has to be an easy way, I just havn't found it yet...

    Cheers,
    schmaunz



  • Hi, try
    QDateTime::currentMSecsSinceEpoch() - QDateTime(QDate::currentDate()).toMSecsSinceEpoch();



  • [quote author="hskoglund" date="1402587810"]
    QDateTime::currentMSecsSinceEpoch() - QDateTime(QDate::currentDate()).toMSecsSinceEpoch();
    [/quote]

    That is exactly what I was looking for.
    Thank you very much :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.