I'm trying to get the remaining minutes of the current day, but the Datetime class its giving me headaches. (I'm going crazy)
Datetime now = Datetime.now();//System.now(); System.debug(now); System.debug(now.hour()); System.debug(now.minute()); Integer minutesToAdd = 1440 - ((now.hour() * 60) + now.minute()); System.debug(minutesToAdd); System.debug(now.addMinutes(minutesToAdd));
And I'm getting a debug like
12:23:14:033 USER_DEBUG |DEBUG|2015-10-14 17:23:14 12:23:14:033 USER_DEBUG |DEBUG|19 12:23:14:033 USER_DEBUG |DEBUG|23 12:23:14:034 USER_DEBUG |DEBUG|277 12:23:14:034 USER_DEBUG |DEBUG|2015-10-14 22:00:14
Why is the hour different in the first and second debug line? Shouldn't it be the same?
In the fifth line, first I'm calculating the minutes that have happened in the day by multiplying the hours (0-24) by 60 and adding the minutes in the current hour, and then I'm subtracting this value to the total minutes in a day (1440).
What I was hopping to validate with the last debug is that I got the remaining minutes of the day in the
minutesToAdd variable, it should have been something like
2015-10-15 00:00:14 not
What am I doing wrong? Or how could I approach this? I need the remaining minutes.