How to convert SQL Server’s timestamp column to datetime format

SQL Server’s TIMESTAMP datatype has nothing to do with a date and time! It’s just a hexadecimal representation of a consecutive 8 byte integer – it’s only good for making sure a row hasn’t change since it’s been read. You can read off the hexadecimal integer or if you want a BIGINT. As an example: The result is In newer … Read more

Convert datetime to Unix timestamp and convert it back in python

What you missed here is timezones. Presumably you’ve five hours off UTC, so 2013-09-01T11:00:00 local and 2013-09-01T06:00:00Z are the same time. You need to read the top of the datetime docs, which explain about timezones and “naive” and “aware” objects. If your original naive datetime was UTC, the way to recover it is to use … Read more

Get Unix timestamp with C++

C++20 introduced a guarantee that time_since_epoch is relative to the UNIX epoch, and cppreference.com gives an example that I’ve distilled to the relevant code, and changed to units of seconds rather than hours: Using C++17 or earlier, time() is the simplest function – seconds since Epoch, which for Linux and UNIX at least would be the UNIX epoch. Linux manpage here. The … Read more