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, 2019 in Python by sumanth
• 190 points
2,763 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, 2019 by Niharika

selected Oct 30, 2019 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
• 58,020 points
9,959 views
0 votes
1 answer

How to convert string into epoch time?

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

answered Sep 22, 2018 in Python by SDeb
• 13,300 points
6,856 views
0 votes
1 answer

How to convert date string to date object in python?

Use this :-  >>> datetime.datetime.strptime('24052010', "%d%m%Y").date() datetime.date(2010, 5, 24) Hope ...READ MORE

answered Oct 22, 2018 in Python by Priyaj
• 58,020 points
11,253 views
0 votes
1 answer

How to convert each list item into string in a column of data frame. ?

Hey, To split a string you can use ...READ MORE

answered Feb 5, 2020 in Python by Roshni
• 10,480 points
930 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
3,454 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,370 points
1,131 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,300 points
939 views
0 votes
1 answer

Python 3 equivalent of SimpleHTTPServer

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

answered Nov 21, 2018 in Python by SDeb
• 13,300 points
1,012 views
0 votes
1 answer

How to convert .ipynb files into .py?

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

answered Aug 8, 2019 in Python by hansika
16,041 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, 2019 in Python by Raj
2,623 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP