I'm using boto3 and python to get information about objects in an S3 bucket. I' using boto as below:
context = super(s3, self).get_context_data(**kwargs)
data = []
aws = boto3.resource('s3')
buckets = aws.buckets.all()
#Get data from each bucket
for bucket in buckets:
bucketData = {}
totalSize = 0
bucketName = bucket.name
fileBuckets = boto3.resource('s3').Bucket(bucketName)
#Get data for each object inside each bucket
for file in fileBuckets.objects.all():
totalSize += file.size
bucketData['bucketName'] = bucket.name
bucketData['createdAt'] = bucket.creation_date
bucketData['totalSize'] = file_size(totalSize)
data.append(bucketData)
context['buckets'] = data
return context
And I display the creation date in the template like this:
<ul id='s3ItemDesc'>
<li>{{ bucket.createdAt }}</li>
<li>{{ bucket.totalSize }}/4GB</li>
<li>
This is fine however I want to change the datetime stamp to just date. Currently I'm getting this:
Dec. 3, 2017, 2:11 p.m
But I would like to change it to display date only:
3/12/2017
I've been googling for a while but couldn't find anything. Any idea how this can be achieved?