def get_list_of_timestamps(s3_session, bucket_name, max_records=None):
    """Get a list of timestamps for all objects in selected S3 bucket."""
    # Construct object that represents the bucket in S3.
    bucket = s3_session.Bucket(bucket_name)

    n = 0
    timestamps = []

    # Iterate over all objects found in given bucket. Please be avare that this
    # operation might be time and/or memory consuming.
    for obj in bucket.objects.all():
        timestamps.append(obj.last_modified)

        # It is possible to limit number of records. If `max_records` is set to
        # `None`, limits are not used.
        if max_records is not None:
            n += 1
            if n >= max_records:
                break

    return timestamps