In the one action, you're getting the beginning of the current day in UTC. The beginning of this day in UTC is yesterday in your local time (session time). When you format the datetime and make it localized, it shows you yesterday for that reason.
Using formatDateTimeUTC instead should give you the result that you want if you're looking for the UTC date.