Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 639843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:53:15+00:00 2026-05-13T20:53:15+00:00

Working on a script to collect users browser history with time stamps ( educational

  • 0

Working on a script to collect users browser history with time stamps ( educational setting).
Firefox 3 history is kept in a sqlite file, and stamps are in UNIX epoch time… getting them and converting to readable format via a SQL command in python is pretty straightforward:

sql_select = """ SELECT datetime(moz_historyvisits.visit_date/1000000,'unixepoch','localtime'), 
                        moz_places.url 
                 FROM moz_places, moz_historyvisits 
                 WHERE moz_places.id = moz_historyvisits.place_id
             """
get_hist = list(cursor.execute (sql_select))

Chrome also stores history in a sqlite file.. but it’s history time stamp is apparently formatted as the number of microseconds since midnight UTC of 1 January 1601….

How can this timestamp be converted to a readable format as in the Firefox example (like 2010-01-23 11:22:09)? I am writing the script with python 2.5.x ( the version on OS X 10.5 ), and importing sqlite3 module….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:53:15+00:00Added an answer on May 13, 2026 at 8:53 pm

    This may not be the most Pythonic code in the world, but here’s a solution: Cheated by adjusting for time zone (EST here) by doing this:

    utctime = datetime.datetime(1601,1,1) + datetime.timedelta(microseconds = ms, hours =-5)
    

    Here’s the function : It assumes that the Chrome history file has been copied from another account into /Users/someuser/Documents/tmp/Chrome/History

    def getcr():
        connection = sqlite3.connect('/Users/someuser/Documents/tmp/Chrome/History')
        cursor = connection.cursor()
        get_time = list(cursor.execute("""SELECT last_visit_time FROM urls"""))
        get_url = list(cursor.execute("""SELECT url from urls"""))
        stripped_time = []
        crf = open ('/Users/someuser/Documents/tmp/cr/cr_hist.txt','w' )
        itr = iter(get_time)
        itr2 = iter(get_url)
    
        while True:
            try:
                newdate = str(itr.next())
                stripped1 = newdate.strip(' (),L')
                ms = int(stripped1)
                utctime = datetime.datetime(1601,1,1) + datetime.timedelta(microseconds = ms, hours =-5)
                stripped_time.append(str(utctime))
                newurl = str(itr2.next())
                stripped_url = newurl.strip(' ()')
                stripped_time.append(str(stripped_url))
                crf.write('\n')
                crf.write(str(utctime))
                crf.write('\n')
                crf.write(str(newurl))
                crf.write('\n')
                crf.write('\n')
                crf.write('********* Next Entry *********') 
                crf.write('\n')
            except StopIteration:
                break
    
        crf.close()            
    
        shutil.copy('/Users/someuser/Documents/tmp/cr/cr_hist.txt' , '/Users/parent/Documents/Chrome_History_Logs')
        os.rename('/Users/someuser/Documents/Chrome_History_Logs/cr_hist.txt','/Users/someuser/Documents/Chrome_History_Logs/%s.txt' % formatdate)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.