-2

I have a very simple list like this :

['Monday,30 December,2013', 'Delivered_it', '19:23', '1']

Please guide me how to extract from this list the date , status and time

NOTE : I don't simply want to extract it like a string but as a date.time objects so that I could do some analysis on it .

Anurag Pandey
  • 373
  • 2
  • 5
  • 21
  • Please share your code and error if any. Please help us to help you. Please check this link - http://stackoverflow.com/help/how-to-ask – Dinesh Pundkar Aug 23 '16 at 05:43
  • 6
    Possible duplicate of [Converting string into datetime](http://stackoverflow.com/questions/466345/converting-string-into-datetime) – Dinesh Pundkar Aug 23 '16 at 05:52
  • Possible duplicate of http://stackoverflow.com/questions/19068269/how-to-convert-a-string-date-into-datetime-format-in-python – Dinesh Pundkar Aug 23 '16 at 05:52
  • See [datetime.datetime.strptime](https://docs.python.org/2/library/datetime.html#datetime.datetime.strptime). – Mark Tolonen Aug 23 '16 at 06:14

1 Answers1

1
import datetime

data = ['Monday,30 December,2013', 'Delivered_it', '19:23', '1']
data = '{} {}'.format(data[0], data[2])
timestamp = datetime.datetime.strptime(data, '%A,%d %B,%Y %H:%M')
print timestamp # 2013-12-30 19:23:00
turkus
  • 4,637
  • 2
  • 24
  • 28
drootnar
  • 133
  • 1
  • 2
  • 10