How can I convert a Python datetime object to UTC? -


i have python datetime object convert utc. planning output in rfc 2822 format put in http header, not sure if matters question. found information on site converting time objects, , looks simpler way, time want use datetime objects, because using timedeltas adjust them:

i tried this:

from datetime import datetime, timedelta  = datetime.now() fiveminuteslater = datetime.now() + timedelta(minutes=5) fiveminuteslaterutc = ??? 

nothing in time or datetime module looks me. seems may able passing datetime object through 3 or 4 functions, wondering if there simpler way.

i prefer not use third-party modules, may if reasonable choice.

from datetime import datetime, timedelta datetime.utcnow() + timedelta(minutes=5) 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -