Cannot parse the date in Python

I need to parse date and time. Here is what I've got:

import time
a = time.strptime('Apr 28 2013 23:01', "%b %d %y %H:%M")
print a 

But it gives me

Traceback (most recent call last):
  File "/home/aaa/Documents/", line 17, in <module>
    a = time.strptime('Apr 28 2013 23:01', "%b %d %y %H:%M")
  File "/usr/lib/python2.7/", line 467, in _strptime_time
    return _strptime(data_string, format)[0]
  File "/usr/lib/python2.7/", line 325, in _strptime
    (data_string, format))
ValueError: time data 'Apr 28 2013 23:01' does not match format '%b %d %y %H:%M'

What am I doing wrong?


%y should be %Y for a 4 digit year...

From the docs:

%y  Year without century as a decimal number [00,99].    
%Y  Year with century as a decimal number.

Need Your Help

survey php mysql counter

php mysql html counter

I am working on a small php/mysql survey.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.