Apple - See website visit time in Safari history

So I woke up today to my sleep-tracker app telling me I went to bed an hour earlier than I thought I did, so naturally I assumed the app was the one who made the stupid mistake. Luckily I'd surfed the web before going to bed, but apparently Apple changed things up again as of High Sierra or Safari 11 so the other answers didn't work for me.

I found out how to get the visit times, and since I went way to far to get to the bottom of this highly unimportant issue already, I thought I'd share my findings here:

Edit

Okay so I got carried away a little more and wrote a bash one-liner to do all the hard work for you. Just open the terminal and copy-past it in. It should work without having to install anything, unless apple has changed something again in the mean time.

You can ignore the empty lines in the output (they are http-redirects) and you can change the last number 30 in the command to filter the number of lines you want to see.

sqlite3 ~/Library/Safari/History.db 'select visit_time,title from history_visits order by visit_time desc;' \
 | while read i; do d="${i%%.*}"; echo "$(date -r $((d+978307200))) | ${i#*|}"; done \
 | head -n 30

Original answer

So instead of having a simple folder with all the history like before, they now write the history into a database. Here's how you get the info if you really want to:

  1. The data is now stored in an SQLite Database, so you're gonna need some tool to read that. I suggest the DB Browser for SQLite. Just install it the usual way.
  2. Now open the database file. It is located here: /Users/[yourname]/Library/Safari/History.db.
  3. In the Browse Data Tab click the Table: dropdown and select history_visits. History_visits screenshot
  4. Now, sort by visit_time and find the thing you are interested in.
  5. Those numbers under the visit_time column are a Core Data Timestamp, so to get something human-readable you need a converter. Simply use this one: https://www.epochconverter.com/coredata

Hope this solves your history-related conundrum.


I just tried this in 10.11.4 and it works; you can see the history. If someone clears the cache, this goes away.

Go to the following location:

/Users/yourname/Library/Caches/Metadata/Safari/History/

From here you can change the view to List View and sort by Date Modified.


I modified the oneliner that meonlol gave above. This way it is just pure SQL query.

sqlite3 ~/Library/Safari/History.db \
    'SELECT datetime(visit_time+978307200, "unixepoch", "localtime"), title
     FROM history_visits
     ORDER BY visit_time DESC
     LIMIT 30;'

In Mojave, and possibly later, accessing the file in terminal seems limited. Either grant full access to Terminal in System Preferences or use Finder to open ~/Library/Safari and then copy History.db to somewhere else.

Tags:

Safari