Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to convert time from one timezone to another in python

from datetime import datetime
from pytz import timezone
format = "%Y-%m-%d %H:%M:%S %Z%z"
# Current time in UTC
now_utc = datetime.now(timezone('UTC'))
print(now_utc.strftime(format))
# Convert to Asia/Kolkata time zone
now_asia = now_utc.astimezone(timezone('Asia/Kolkata'))
print(now_asia.strftime(format))
Comment

how to convert time from one timezone to another in python

$ pip install pytz
Comment

PREVIOUS NEXT
Code Example
Python :: python json 
Python :: import os in python 
Python :: python webview 
Python :: @ in python 
Python :: count pairs with given sum python 
Python :: create new spreadsheet 
Python :: variable referenced before assignment python 
Python :: split rows into multiple columns in pandas 
Python :: data encapsulation in python 
Python :: drop columns 
Python :: how to create list of objects in python 
Python :: how to write something in python 
Python :: remove item in dict 
Python :: python package install 
Python :: .extend python 
Python :: how to read an xml file 
Python :: python string and integer concatenation 
Python :: create and add many to many field in django 
Python :: hash table python 
Python :: how to add number in tuple 
Python :: python dict 
Python :: print column name and index 
Python :: pivot tables pandas explicación 
Python :: unzipping the value using zip() python 
Python :: convert from R to python 
Python :: Python - Comment supprimer Commas de la corde 
Python :: how to make a window in python ursina 
Python :: Pipeline_parameters 
Python :: daemon in os 
Python :: python with statement variables 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =