datetime question

Mark Lawrence breamoreboy at
Fri Nov 8 23:18:46 CET 2013

On 08/11/2013 22:01, Νίκος Αλεξόπουλος wrote:
> Στις 8/11/2013 11:29 μμ, ο/η Mark Lawrence έγραψε:
>> On 08/11/2013 21:11, Νίκος Αλεξόπουλος wrote:
>>> 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.
> I saw the link and i'm wondering if it can be written in 1-liner.
> Don't get me wrong but i had the lastvisit calculated on 1 statement and
> i want to retain it this way.
> Is it possible?

Yes, but I'll leave you to work out how to do it, on the grounds that I 
have a very, very strong suspicion about the way this thread is going to go.

Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

More information about the Python-list mailing list