code: def format_datetime(self, time_input, tz=None, date_format=None):
          
  
          # handle timestamp (e.g. 1510686617 or 1510686617.298753)
          dt_value = self.any_to_datetime(time_input, tz)
  
          # format date
          if date_format == '%s':
              dt_value = calendar.timegm(dt_value.timetuple())
          elif date_format:
              dt_value = dt_value.strftime(date_format)
          else:
              dt_value = dt_value.isoformat()
  
          return dt_value
docs: Return timestamp from multiple input formats.
  
              Formats:
  
              #. Human Input (e.g 30 days ago, last friday)
              #. ISO 8601 (e.g. 2017-11-08T16:52:42Z)
              #. Loose Date format (e.g. 2017 12 25)
              #. Unix Time/Posix Time/Epoch Time (e.g. 1510686617 or 1510686617.298753)
  
          .. note:: To get a unix timestamp format use the strftime format **%s**. Python
                    does not natively support **%s**, however this method has support.
  
          Args:
              time_input (string): The time input string (see formats above).
              tz (string): The time zone for the returned data.
              date_format (string): The strftime format to use, ISO by default.
  
          Returns:
              (string): Formatted datetime string.