You did most of the work.
I did not know epoch existed as well. Creating logic for getTimeParts() was the hardest thing which I just extracted into a funciton. I just followed what others were saying, took the parts of the code and optimized it in a way that it can hold multiple formatting options