Factor out a getTimestamp function.