def datetime_to_str(date=None, format='%Y-%m-%d %H:%M:%S'):
    """
    this method will convert the datetime into string with the format YYYY-mm-dd HH:MM:SS

    @Args:
    * [date] datetime.datetime, without any input the returning will be the current timestamp
    * [format] str, the format of output string
    
    @Returns:
    * [str] formatted string of timestamp
    """
    from datetime import datetime
    if date is None:
        date = datetime.now()
    if type(date) is not datetime:
        return '1970-01-01 00:00:00'
    return date.strftime(format)
