Datetime Error

6 views
Skip to first unread message

HJ

unread,
May 26, 2020, 3:12:34 AM5/26/20
to Django users
hello django-users hope you are doing well ! 

I was trying to convert the Date from string to timestamp 

def JsonDeliv(request):
 
 dataset = DeliveriesperDate.objects.all().values_list('Date','CountDeliveries')
 data = list(dataset)

  for i in data :
   data[i][0] = int(time.mktime(time.strptime(str(i),'%Y-%m-%dT%H:%M:%S.%Z'))*1000)

  return JsonResponse(data, safe=False)



this is the error I get : ValueError: time data '(datetime.datetime(2020, 5, 21, 0, 0, tzinfo=<UTC>), 5)' does not match format '%Y-%m-%dT%H:%M:%S.%Z'

can you guys help me out !
Reply all
Reply to author
Forward
0 new messages