how to convert date field into UTC format (2019-10-29T19:20:30.45Z)

0 votes
Hi i have a date field which i need to convert into to UTC format which is (2019-10-29T02:20:30.45Z)

this is the value from the date field that i am getting = 10-29-2019 02:32.

please could any one help me crack this .

Note :  i have tried multiple things like but not able to get it in this format , especially 45Z part of the format .
Oct 29 in Python by sumanth
• 190 points
94 views

1 answer to this question.

+1 vote
Best answer

Hey, I think this should do what you want:

import datetime

time_str = "10-29-2019 02:32"
time_str1 = time_str.split(" ")
time_str = (time_str1[0]+'T'+time_str1[1]+':00Z') #convert time to utc string format

strip = datetime.datetime.strptime(time_str,'%m-%d-%YT%H:%M:%SZ') #convert string to datetime object

answered Oct 29 by Niharika

selected Oct 30 by sumanth

Related Questions In Python

0 votes
1 answer

How to convert datetime.date to UTC timestamp in Python

In Python 3 (< 3.3) From the docs ...READ MORE

answered Oct 31, 2018 in Python by Priyaj
• 56,920 points
2,749 views
0 votes
1 answer

How to convert string into epoch time?

you are passing the parsed datetime object to ...READ MORE

answered Sep 21, 2018 in Python by SDeb
• 13,180 points
264 views
0 votes
1 answer

How to convert date string to date object in python?

Use this :-  >>> datetime.datetime.strptime('24052010 ...READ MORE

answered Oct 22, 2018 in Python by Priyaj
• 56,920 points
273 views
0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
787 views
0 votes
1 answer

Install pip in Python 3.4

Don't worry! Python already comes in default ...READ MORE

answered May 1, 2018 in Python by aayushi
• 750 points
90 views
0 votes
1 answer

python3 pip not working

The name of your package in PyPI ...READ MORE

answered Sep 4, 2018 in Blockchain by slayer
• 29,170 points
65 views
0 votes
1 answer

How is Python 2.7.3 and Python 3.3 different?

raw_input() is not used in Python 3. Use input()  ...READ MORE

answered Sep 12, 2018 in Python by SDeb
• 13,180 points
36 views
0 votes
1 answer

Python 3 equivalent of SimpleHTTPServer

The SimpleHTTPServer module has been merged into ...READ MORE

answered Nov 20, 2018 in Python by SDeb
• 13,180 points
99 views
0 votes
1 answer

How to convert .ipynb files into .py?

You can use this command to convert ...READ MORE

answered Aug 7 in Python by hansika
43 views
0 votes
1 answer

How to convert string in Pandas Series to lower case?

Suppose you have the series stored in ...READ MORE

answered May 13 in Python by Raj
284 views