import datetime [...my code]. # Return a value from csv file. date = worksheet.cell(0, 0).value # Convert the value to the date. dat1 = datetime.date.fromtimestamp(date) ...and this gives me 1970-01-01 instead of 2015-09-05 for some reason.
from datetime import datetime datetime_object = datetime.strptime('2015/9/5', '%Y/%m/%d').date() datetime_string = datetime_object.strftime("%Y/%-m/%-d") print 'As datetime object: ' + str(datetime_object) print 'As string: ' + datetime_string
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)