Actually I am a newbie in python and there is the code that worries me a lot.
import time
from datetime import time, date, datetime
createdAt ='Wed Jan 12 11:45:28 +0000 2011' # createdAt value is read from a file
print 'CR= ',createdAt
struct_time = datetime.strptime(str(createdAt),'%a %b %d %H:%M:%S +0000 %Y').strftime('%s') # notice small s here
print "returned tuple: %s " % struct_time
I am getting an error like this in my compiler Python 2.7.10 Shell
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
asd = datetime.strptime(str(createdAt),'%a %b %d %H:%M:%S +0000 %Y').strftime('%s')
ValueError: Invalid format string
but in online compiler I am getting an output like this (online compiler at https://ideone.com/g0R2xw)
CR= Wed Jan 12 11:45:28 +0000 2011
returned tuple: 1294832728
I want my output to be this. Also if you can kindly tell me how this is calculated. Thank You in advance...