Python: How to convert google location timestaMps in a year-month-day-hour-minute-seconds format?
Question: I am playing around with my google location data (which one can download here
<https://takeout.google.com/settings/takeout>).

The location data is a json file, of which one variable is 'timestaMps' (e.g.
one observation is "1475146082971"). How do I convert this into a datetime?

Thanks!


Answer: Use
[fromtimestamp](https://docs.python.org/2/library/datetime.html#datetime.date.fromtimestamp)
method from datetime module. To convert your 'timestaMps' to timestamp you
need to convert it to int(). Formating of timestamp is done with
[strftime()](https://docs.python.org/2/library/time.html#time.strftime).

    
    
    from datetime import datetime
    datetime.fromtimestamp(int("1475146082971")).strftime('%Y-%m-%d %H:%M:%S')
    

