python - Date Conversion Django Error -
i have date here fri jun 19 02:27:25 pdt 2015
db , trying convert pdt utc first converting datetime object this:
date_time = datetime.datetime.strptime(date, '%a %b %d %h:%m:%s %z %y');
when run python file directly, works, when code executes thru django framework, error.
valueerror: time data 'fri jun 19 02:27:25 pdt 2015' not match format '%a %b %d %h:%m:%s %z %y'
i have feeling because of timezone, because have many more date formats don’t contain timezone , conversion them works fine. suggest workaround this.
this error raised because datetime
module not recognize time-zones, use dateutil
module instead of datetime
similar below:
from dateutil.parser import parse parse('fri jun 19 02:27:25 pdt 2015')
Comments
Post a Comment