I want to convert an ISO-8601 character string to Japan time

I want to convert an ISO-8601 character string to Japan time

2020-09-25T18:00:00Z2020-09-26 03:00:00

Program in python

I don't think I need such a long program by any means ...

# coding: utf-8
from datetime import datetime, timezone, timedelta
import dateutil.parser

def time_jst(date_str: str):
    date_str.replace('Z', '+00:00')
    t = dateutil.parser.parse(date_str)
    JST = timezone(timedelta(hours=+9))
    t_jst = t.astimezone(JST)
    ret = t_jst.strftime("%Y-%m-%d %H:%M:%S")
    return ret

s = '2020-09-25T18:00:00Z'
print (time_jst(s))

Recommended Posts

I want to convert an ISO-8601 character string to Japan time
I want to split a character string with hiragana
Convert a string to an image
For the time being, I want to convert files with ffmpeg !!
I want to make an automation program!
I want to extract an arbitrary URL from the character string of the html source with python
Mayungo's Python Learning Episode 6: I tried to convert a character string to a number
I want to batch convert the result of "string" .split () in Python
I want to color a part of an Excel string in Python
[Question] I want to scrape a character string surrounded by unique tags!
I tried to generate a random character string
Convert the world time zone time string to Japan time without calculating the time difference with python.
I want to store the result of% time, %% time, etc. in an object (variable)
I want to embed a variable in a Python string
I want to develop an Android application on Android (debugging)
I want to restart CentOS 8 on time every day.
Convert hexadecimal string to binary
[python] Convert date to string
Date and time ⇔ character string
I want to solve Sudoku (Sudoku)
I want to create a Dockerfile for the time being.
I want to specify a file that is not a character string for logrotate, but is it impossible?
I want to record the execution time and keep a log.
I want to use an external library with IBM Cloud Functions
I want to convert vertically held data (long type) to horizontally held data (wide type)
I want to understand systemd roughly
I want to scrape images to learn
I want to do ○○ with Pandas
I want to copy yolo annotations
I want to debug with Python
I want to operate DB using Django's ORM from an external application
I want to separate the processing between test time and production environment
Tips for manipulating numpy.ndarray from c ++ -I want to use an iterator-
I want to be cursed by a pretty girl every time I sudo! !!
I want to display an image on Jupyter Notebook using OpenCV (mac)
I want to convert a table converted to PDF in Python back to CSV
I tried to convert datetime <-> string with tzinfo using strftime () and strptime ()
I want to leave an arbitrary command in the command history of Shell
I want to create an Ubuntu chrome User Profile with Colab only
Python: I want to measure the processing time of a function neatly
I want to pin Spyder to the taskbar
I want to detect objects with OpenCV
I want to output to the console coolly
I want to print in a comprehension
I want to handle the rhyme part1
Set the time zone to Japan Standard Time
How to convert Python to an exe file
I want to know how LINUX works!
I want to blog with Jupyter Notebook
Convert (compress) formatted JSON string to 1-line JSON
I want to handle the rhyme part3
I want to use jar from python
I want to build a Python environment
I want to use Linux on mac
I want to pip install with PythonAnywhere
[Python] How to invert a character string
I want to analyze logs with Python
I want to play with aws with python
[Pandas] Expand the character string to DataFrame
I want to use IPython Qt Console
I want to display the progress bar