need to print seconds from the epoch including the millisecond

matt.doolittle33 at gmail.com matt.doolittle33 at gmail.com
Thu Dec 26 17:06:17 EST 2013


On Thursday, December 26, 2013 2:22:10 PM UTC-5, Dan Stromberg wrote:
> On Thu, Dec 26, 2013 at 10:32 AM,  <matt.doolittle33 at gmail.com> wrote:
> 
> > i am using 2.7.   I need to print the time in seconds from the epoch with millisecond precision.  i have tried many things but have failed.  heres my latest:
> 
> >
> 
> >         from time import time, strftime
> 
> >         from datetime import datetime, time
> 
> >
> 
> >         #  write date, time, then seconds from epoch
> 
> >         self.logfile.write('%s\t'%(strftime("%Y-%m-%d",)))
> 
> >         self.logfile.write('%s\t'%(now.strftime("%H:%M:%S",)))
> 
> >         self.logfile.write('%s\t'%(now.time()))
> 
> 
> 
> In [1]: import time
> 
> 
> 
> In [2]: time.time()
> 
> Out[2]: 1388085670.1567955
> 
> 
> 
> HTH

OK i did what you said but I am only getting 2 decimal places.  
Why is this and what can I do to get the millisecond?  



More information about the Python-list mailing list