code: def get_solr_date(pydate, is_negative):
      
      # check if date is valid and then set it to solr format YYYY-MM-DDThh:mm:ssZ
      try:
          if isinstance(pydate, datetime.datetime):
              solr_date = '%sZ' % pydate.isoformat()[0:19]
              if is_negative:
                  LOGGER.debug('%s This layer has a negative date' % solr_date)
                  solr_date = '-%s' % solr_date
              return solr_date
          else:
              return None
      except Exception, e:
          LOGGER.error(e, exc_info=True)
          return None
docs: Returns a date in a valid Solr format from a string.