Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29364
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: utcnow |
| References | <mailman.822.1347855926.27098.python-list@python.org> |
| Date | 2012-09-17 14:48 +1000 |
| Message-ID | <87vcfdl0fq.fsf@benfinney.id.au> (permalink) |
| Organization | Unlimited download news at news.astraweb.com |
Nick the Gr33k <nikos.gr33k@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
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
utcnow Nick the Gr33k <nikos.gr33k@gmail.com> - 2012-09-17 07:25 +0300 Re: utcnow Ben Finney <ben+python@benfinney.id.au> - 2012-09-17 14:48 +1000
csiph-web