Get UTC time in MM-DD-YYYY format

I know how to format a string from the juce::Time object, but I can’t for the life of me seem to get proper UTC time. My local time is 4/18/2024 and UTC time is 4/19/2024 and no matter what I do I can only seem to get 4/18/2024 from the juce::Time object.

I think there is something I am not understanding about the way the Time object works as it seems like this should be simple.

Just looking at the docs, have you tried something like the following? (Untested!)

auto now = Time::getCurrentTime();
auto offset = RelativeTime::seconds(now.getUTCOffsetSeconds());
auto currentUTCtime = now + offset;
// Format as desired

Probably need to subtract the offset

Thanks @jwatson53, you’re correct - getUTCOffsetSeconds does indeed give you the your local offset from UTC (Americas in the negative, Asias in the positive), not UTC’s offset from your local time zone…

Makes more sense this way!

Awesome, thanks! That did the trick. I tried something similar with trying to get the UTC offset and subtract it, but I will doing it as milliseconds and with the Time constructor and it didn’t seem to get the correct results.

Thanks again! I knew it was something simple.