Added ternary operator for final result. Discovered error due to not using AM or PM.