def format_timestamp ( timestamp ) : tz_info = tz . tzutc ( ) return datetime . fromtimestamp ( timestamp , tz = tz_info ) . strftime ( "%Y-%m-%dT%H:%M:%S.000Z" )
datetime format for elasticsearch python
Format the UTC timestamp for Elasticsearch eg . 2014 - 07 - 09T08 : 37 : 18 . 000Z
def format_timestamp(timestamp):
        """
        Format the UTC timestamp for Elasticsearch
        eg. 2014-07-09T08:37:18.000Z

        @see https://docs.python.org/2/library/time.html#time.strftime

        :type timestamp int
        :rtype: str
        """
        tz_info = tz.tzutc()
        return datetime.fromtimestamp(timestamp, tz=tz_info).strftime("%Y-%m-%dT%H:%M:%S.000Z")