The time fields use a standard timestamp number (in seconds from standard epoch). That number can be converted to a date/time by using the python datetime module.
% python
>>> import datetime
>>> import qb
>>> t = qb.jobinfo(id=1500)[0]['timestart']
>>> print t
1221804327
>>> d = datetime.datetime.fromtimestamp(t)
>>> print d
2008-09-18 23:05:27
To convert timestamps to this more readable form in-place within the job dicts, you can use the following code snippet:
import qb
import datetime
jobs = qb.jobinfo()
for j in jobs:
for k in('timesubmit', 'timestart', 'timecomplete'):
j[k] = datetime.datetime.fromtimestamp(j[k])
Result
Combining the datetime conversion code with the csv code produces:
import qb
import csv
import datetime
# Get a list of all the jobs. See qb.jobinfo() docs for how to get a subset of the jobs
jobs = qb.jobinfo()
# Convert all timestamps to datetime format
for j in jobs:
for k in('timesubmit', 'timestart', 'timecomplete'):
j[k] = datetime.datetime.fromtimestamp(j[k])
# Write out the csv file
keysList = jobs[0].keys() # List of the keys to write out. Alternative: ['id', 'name'], etc.
f = open('/tmp/aaa.csv', 'w') # Open a csv file for writing
c = csv.DictWriter(f, keysList) # Attach a csv dict writer to that file
c.writerow(dict([(k,k) for k in keysList])) # Add a title line to the csv file
c.writerows(jobs) # Write out the job info for the specified fields
f.close() # Close the file