0

This is the date format of AWS, how can I parse using and separate year day months and so on.

snapshot_time = str(snapshot_name.snapshot_create_time) snapshot_year = datetime.datetime.strptime(snapshot_time,"%Y-%m-%d-%H").year

Error: ValueError: time data '2014-08-09T04:31:39.870Z' does not match format '%Y-%m-%d-%H' I agree with the error, but how to fix it. I think part 09T04 is the problem area

Anup Singh
  • 313
  • 1
  • 5
  • 18
  • http://stackoverflow.com/questions/969285/ should help – Will Sep 08 '14 at 18:48
  • Got it thanks, snapshot_time = str(snapshot_name.snapshot_create_time) snapshot_time = dateutil.parser.parse(snapshot_time) snapshot_year = snapshot_time.astimezone(dateutil.tz.tzutc()).year – Anup Singh Sep 09 '14 at 19:25

1 Answers1

0
snapshot_time = str(snapshot_name.snapshot_create_time)
snapshot_time = dateutil.parser.parse(snapshot_time)
snapshot_year = snapshot_time.astimezone(dateutil.tz.tzutc()).year
Anup Singh
  • 313
  • 1
  • 5
  • 18