Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,938 questions

51,875 answers

573 users

How to convert string into datetime in Python

3 Answers

0 votes
from datetime import datetime
 
dt = datetime.strptime('Apr 10 2019 2:46PM', '%b %d %Y %I:%M%p')
 
print(dt)
 
 
 
'''
run:
 
2019-04-10 14:46:00
 
'''

 



answered Apr 10, 2019 by avibootz
edited Feb 4, 2020 by avibootz
0 votes
from datetime import datetime

dt = datetime.strptime('2020-02-04T11::03::26.348791', '%Y-%m-%dT%H::%M::%S.%f')
 
print(dt)
 
 
  
  
'''
run:
  
2020-02-04 11:03:26.348791
  
'''

 



answered Feb 4, 2020 by avibootz
0 votes
from datetime import datetime
 
dt = datetime.strptime('03/Feb/2020 11:15:21', '%d/%b/%Y %H:%M:%S')
 
print(dt)
 

 
'''
run:

2020-02-03 11:15:21
 
'''

 



answered Feb 4, 2020 by avibootz

Related questions

2 answers 173 views
2 answers 156 views
1 answer 130 views
3 answers 307 views
3 answers 205 views
3 answers 174 views
...