You know the answer. Store UTC. In Python that's datetime.now(timezone.utc), or use integer epoch. Convert when you display. For the old rows, you can't tell the two 01:30s apart from the text alone, but the rows are ordered by rowid, and readings are every five minutes. Where the time goes backwards, you've found the switch.