Member-only story

Ross Bulat
5 min readAug 9, 2018

--

Using Coinmarketcap Pro and CryptoCompare APIs around manipulating timestamps in Python

You’re building your backend web services with Python and things are going swimmingly. Apart from one thing — every service seems to be using a different timestamp format. Whilst we wish that all services would stick to one format, this is just not the case.

Luckily Python provide the tools to convert timestamps of various formats into a datetime object, where we can then manipulate them as we wish. This article gives you a taster of how to do this.

Checking your system timezone

Before we manipulate time in Python, make sure you know which timezone your system is running:

import timeprint(time.tzname)
print(time.time())
> [UTC, UTC]

time.time() gives us 2 values, the timezone not accounting for daylight savings, and the timezone accounting for daylight savings. What if we don’t want to worry about DST issues? Stick to UTC time.

The switch to daylight saving time does not affect UTC. It refers to time on the zero or Greenwich meridian, which is not adjusted to reflect changes either to or from Daylight Saving Time. — nhc.noaa.gov

--

--

Ross Bulat
Ross Bulat

Written by Ross Bulat

Programmer and Author. @ Parity Technologies, JKRB Investments

No responses yet