Back to Community
How to log the current time?

Newbie question: I noticed when I use print or log.info(), the current date is printed, but not hour / minute. Is it possible to show the complete timestamp?

3 responses

Newbie here too.

I was wondering how to get historical bar timestamps during backtesting. Looked in API Documentation and in zipline API, but didn't find anything yet.

This Python code prints local time for somewhere other than where I currently reside...

import time  
localtime = time.asctime(time.localtime(time.time()))  
print "Local current time :", localtime  
log.info("{}: ...".format(get_datetime('US/Eastern').time()), ...)  

This prints the time where the exchanges are located. You can pass your own timezone string if you want. Quantopian servers don't know which timezone you reside in.

Yeah get_datetime seems to be the way to go, thanks. Still don't understand why print / log.info doesn't show timestamp by default...