? The timestamp can be simply understood as the number of seconds that have passed since 1970/01/01/ 00:00:00 to now. If you want to calculate date operations, because it involves running years, generally use the language's own The library implementation is relatively simple and efficient. But if you just want to get the time, minutes and seconds, you can do it without relying on the library. It can be implemented through modular operation and rounding operation, and the performance is more efficient than the internal library function.
Running results, 1 million times
10 million times
The performance is nearly 200% faster. If it involves big data analysis scenarios, millions or even thousands of times This algorithm is still meaningful when called thousands of times