Nick the Gr33k <nikos.gr...@gmail.com> writes: > Hello is there a better way of writing this: > > date = ( datetime.datetime.utcnow() + datetime.timedelta(hours=3) > ).strftime( '%y-%m-%d %H:%M:%S') > > something like: > > date = datetime.datetime.utcnow(hours=3).strftime( '%y-%m-%d %H:%M:%S') > > i prefer it if it could be written as this.
Break long complicated statements into simpler statements. You might need to get used to naming your intermediate results. now = datetime.datetime.utcnow() later = now + datetime.timedelta(hours=3) timestamp_text = later.strftime("%Y-%m-%d %H:%M:%S") > Also what about dayligh savings time? What about it? What has your reading of the ‘datetime’ module documentation taught you? -- \ “Don't worry about people stealing your ideas. If your ideas | `\ are any good, you'll have to ram them down people's throats.” | _o__) —Howard Aiken | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list