How to convert mysql date to string in php?

In this tutorial, we will explain to you how you can convert mysql date to string in PHP.

1. Code:

   format($format);
		return (false != $str) ? $str : null;
	}
	
	$str = convertMySqlDateToString("2018-11-15 00:00:00", "d-m-Y");
	echo($str);
    ?> 

2. Example:

Input:

convertMySqlDateToString("2018-11-15 00:00:00", "d-m-Y");
convertMySqlDateToString("2018-11-15 00:00:00", "Y-m-d")

Output:

15-11-2018 
2018-11-15