Article

A faster way to convert a timestamp to Hour, Min, Sec

benjoffe ·Lobsters ·Published 2026-09-07

Nearly all major date/time libraries compute hour, minute and second the same way - slowly . In this article, I will dive deep into this little problem, and demonstrate a seemingly impossible claim: A daily timestamp [0..86399] can be…

From the article

Nearly all major date/time libraries compute hour, minute and second the same way - slowly . In this article, I will dive deep into this little problem, and demonstrate a seemingly impossible claim:

A daily timestamp [0..86399] can be converted into Hour, Minute and Second – with the latency of only two multiplications (and on some targets even lower!) .

This is in contrast to most date libraries which take around 16 cpu-cycles to compute.


Share this resource


Discovered 2026-09-08 Source Lobsters Archive 2026-09 →