Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

tz convert python

from datetime import datetime
from pytz import timezone

fmt = "%Y-%m-%d %H:%M:%S %Z%z"
timezonelist = ['UTC','US/Pacific','Europe/Berlin']
for zone in timezonelist:

    now_time = datetime.now(timezone(zone))
    print now_time.strftime(fmt)
Comment

tz convert python

import datetime
import pytz

def convert_datetime_timezone(dt, tz1, tz2):
    tz1 = pytz.timezone(tz1)
    tz2 = pytz.timezone(tz2)

    dt = datetime.datetime.strptime(dt,"%Y-%m-%d %H:%M:%S")
    dt = tz1.localize(dt)
    dt = dt.astimezone(tz2)
    dt = dt.strftime("%Y-%m-%d %H:%M:%S")

    return dt
Comment

PREVIOUS NEXT
Code Example
Python :: python regex get start end indices for searching word 
Python :: extract parameter of voice using python 
Python :: python multiply numbers nested list 
Python :: init matrix in numpy 
Python :: databases not showing in odoo 13 
Python :: how to load csv file pyspark in anaconda 
Python :: pandas add prefix to some range of columns 
Python :: docs in python parameter 
Python :: pillow update image 
Python :: pyqt curves exemple 
Python :: jupyter notebook prevent open browser 
Python :: get top feature gridsearchcv 
Python :: network setting for virtualbox kali 
Python :: how to code a discord bot in python nextcord 
Python :: convert dictionary to 2d array python 
Python :: django get without exception 
Python :: python integrated with activeX 
Python :: shorthand python if 
Python :: create empty polygon python 
Python :: np.argmax python could not be evaluated 
Python :: How to put a header title per dataframe after concatenate using pandas in python 
Python :: python selenium not returning correct source 
Python :: what is comma in regex 
Python :: passport ocr python 
Python :: removing stop words in python 
Python :: activate inherit function django 
Python :: test if instance in queryset django 
Python :: string float to round to 2dp python 
Python :: off to obj python 
Python :: create list 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =