luofeiyu <elearn2...@gmail.com> writes: > import datetime > t1='Sat, 09 Aug 2014 07:36:46 -0700' > t2='Sat, 09 Aug 2014 07:36:46 +0700' > >>> datetime.datetime.strptime(t1,"%a, %d %b %Y %H:%M:%S %z") > datetime.datetime(2014, 8, 9, 7, 36, 46, > tzinfo=datetime.timezone(datetime.timed > elta(-1, 61200))) > >>> datetime.datetime.strptime(t2,"%a, %d %b %Y %H:%M:%S %z") > datetime.datetime(2014, 8, 9, 7, 36, 46, > tzinfo=datetime.timezone(datetime.timed > elta(0, 25200)))
(Your examples will be easier to read – and you will help those who are helping you – if you conform to PEP 8 in the code, and don't break up the output when you copy it here.) > problem : > > t1 is GMT time 2014 00:36:46 > t2 is GMT time 2014 14:36:46 Not true; t1 and t2 are not in the “GMT” zone, they are in UTC-0700 and UTC+0700 respectively. Their value includes that. The instants they *represent* may be equal to the times-plus-timezone you've listed here, but their value is different. The value includes the timezone information, so they're different from what you show. > datetime.datetime.strptime do not give me the right answer. What do you think the right answer would be in each case? Why? -- \ “The aim of science is not to open the door to infinite wisdom, | `\ but to set some limit on infinite error.” —Bertolt Brecht, | _o__) _Leben des Galilei_, 1938 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list