Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #59073
| References | <l5jk15$de$1@dont-email.me> <l5q9me$lk6$1@dont-email.me> |
|---|---|
| Date | 2013-11-11 08:41 -0500 |
| Subject | Re: datetime question |
| From | Joel Goldstick <joel.goldstick@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2377.1384177268.18130.python-list@python.org> (permalink) |
On Mon, Nov 11, 2013 at 4:57 AM, Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> wrote: > Στις 8/11/2013 11:11 μμ, ο/η Νίκος Αλεξόπουλος έγραψε: > >> Is there someway to write the following line even better with the >> ability to detect daylight saving time by itself so i don't have to >> alter the line manually when time changes? >> >> lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime( >> '%y-%m-%d %H:%M:%S' ) # MySQL datetime format >> >> Thanks. > > > > Someone has an idea what to add to this line to automatically adjust itself Three days ago Mark Lawrence pointed you to a stack overflow answer to your question. While it didn't suit your demand for a single line answer, it could easily be made into a function which returned the string format that you requested. You've been around long enough to try to work that out for yourself. If you yourself had returned with a one liner to perform what Mark showed you, I can imagine a lot of people would be impressed at your dedication! I think you are oversimplifying the problem. I recall that you server is in Germany, and you are in Greece. If these are two different time zones, I am guessing that the German time will be given. Also, any linux user who runs package updates regularly (thinking Ubuntu) realizes that some file that starts with tz gets changed quite often. This is because time zones are set by governments, and the date of change from standard to daylight time can be differently, depending upon the location and the governing body. I pose this question to you: Why not display UTC? If it is so important to you to display local time, why do you think that your host's local time is something that is useful for a visitor? Daylight savings time is more complicated that you have suggested > if DST happens? If you insist upon displaying the local time of your server, you should not be hardcoding in a 2 hour difference. Let the python library figure out the delta by giving the country code > -- > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
datetime question Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-11-08 23:11 +0200
Re: datetime question Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-08 21:29 +0000
Re: datetime question Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-11-09 00:01 +0200
Re: datetime question Joel Goldstick <joel.goldstick@gmail.com> - 2013-11-08 17:06 -0500
Re: datetime question rurpy@yahoo.com - 2013-11-11 14:49 -0800
Re: datetime question Joel Goldstick <joel.goldstick@gmail.com> - 2013-11-11 18:18 -0500
Re: datetime question Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-08 22:18 +0000
Re: datetime question Grant Edwards <invalid@invalid.invalid> - 2013-11-08 22:29 +0000
Re: datetime question Chris Angelico <rosuav@gmail.com> - 2013-11-09 09:39 +1100
Re: datetime question Roy Smith <roy@panix.com> - 2013-11-09 10:30 -0500
Re: datetime question Gene Heskett <gheskett@wdtv.com> - 2013-11-09 10:39 -0500
Re: datetime question Chris Angelico <rosuav@gmail.com> - 2013-11-10 09:25 +1100
Re: datetime question Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-08 22:49 +0000
Re: datetime question Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-11-09 01:02 +0200
Re: datetime question Robert Kern <robert.kern@gmail.com> - 2013-11-08 23:23 +0000
Re: datetime question Chris Angelico <rosuav@gmail.com> - 2013-11-09 10:30 +1100
Re: datetime question Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-09 00:12 +0000
Re: datetime question Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-09 12:45 +0000
Re: datetime question Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-11-09 15:43 +0200
Re: datetime question unknown <unknown@unknown.com> - 2013-11-10 12:52 +0000
Re: datetime question Chris Angelico <rosuav@gmail.com> - 2013-11-09 23:52 +1100
Re: datetime question Gene Heskett <gheskett@wdtv.com> - 2013-11-09 19:55 -0500
Re: datetime question Chris Angelico <rosuav@gmail.com> - 2013-11-10 19:47 +1100
Re: datetime question Gene Heskett <gheskett@wdtv.com> - 2013-11-10 04:13 -0500
Re: datetime question Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-11-11 11:57 +0200
Re: datetime question Joel Goldstick <joel.goldstick@gmail.com> - 2013-11-11 08:41 -0500
Re: datetime question Roy Smith <roy@panix.com> - 2013-11-11 09:14 -0500
Re: datetime question Chris Angelico <rosuav@gmail.com> - 2013-11-12 01:25 +1100
Re: datetime question Joel Goldstick <joel.goldstick@gmail.com> - 2013-11-11 09:36 -0500
Re: datetime question Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-11-11 20:59 -0500
Re: datetime question Chris Angelico <rosuav@gmail.com> - 2013-11-12 13:02 +1100
Re: datetime question Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-11-11 21:02 -0500
Re: datetime question Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-11-12 19:30 -0500
Re: datetime question Chris Angelico <rosuav@gmail.com> - 2013-11-13 11:40 +1100
Re: datetime question Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-11 19:19 +0000
Re: datetime question Ethan Furman <ethan@stoneleaf.us> - 2013-11-11 11:39 -0800
Re: datetime question Grant Edwards <invalid@invalid.invalid> - 2013-11-11 20:45 +0000
Re: datetime question mm0fmf <none@mailinator.com> - 2013-11-11 23:21 +0000
Re: datetime question Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-11 23:48 +0000
Re: datetime question Grant Edwards <invalid@invalid.invalid> - 2013-11-12 04:49 +0000
Re: datetime question alex23 <wuwei23@gmail.com> - 2013-11-12 17:25 +1000
Re: datetime question Chris Angelico <rosuav@gmail.com> - 2013-11-12 18:35 +1100
Re: datetime question Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-12 09:20 +0000
Re: datetime question Roy Smith <roy@panix.com> - 2013-11-12 09:18 -0500
Re: datetime question Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-11-12 12:15 +0200
Re: datetime question Andy Lawton <andy@andylawton.eu> - 2013-11-12 12:47 +0000
Re: datetime question Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-11-12 15:32 +0200
Re: datetime question Joel Goldstick <joel.goldstick@gmail.com> - 2013-11-12 09:03 -0500
Re: datetime question Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-11-12 16:12 +0200
Re: datetime question Chris Angelico <rosuav@gmail.com> - 2013-11-13 01:57 +1100
Re: datetime question Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-11-12 17:24 +0200
Re: datetime question Tim Chase <python.list@tim.thechases.com> - 2013-11-12 09:54 -0600
Re: datetime question Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-11-12 17:57 +0200
Re: datetime question Tim Chase <python.list@tim.thechases.com> - 2013-11-12 10:12 -0600
Re: datetime question William Ray Wing <wrw@mac.com> - 2013-11-12 11:14 -0500
Re: datetime question Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-12 16:30 +0000
Re: datetime question MRAB <python@mrabarnett.plus.com> - 2013-11-12 19:09 +0000
Re: datetime question Joel Goldstick <joel.goldstick@gmail.com> - 2013-11-12 14:14 -0500
Re: datetime question Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-12 19:24 +0000
Re: datetime question Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-11-12 19:38 -0500
Re: datetime question Chris Angelico <rosuav@gmail.com> - 2013-11-13 09:42 +1100
Re: datetime question Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-11-12 19:37 -0500
Re: datetime question MRAB <python@mrabarnett.plus.com> - 2013-11-13 01:08 +0000
Re: datetime question Alister <alister.ware@ntlworld.com> - 2013-11-12 16:11 +0000
Re: datetime question Roy Smith <roy@panix.com> - 2013-11-12 19:43 -0500
Re: datetime question Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-12 19:20 +0000
csiph-web