Convert String to DateTime Javascript… Here is the code used to display the above date … It is best to consult the format characters table in the date() function documentation for more information about special cases.. Let's see some practical examples of the date() function now. How can I prevent SQL injection in PHP? 3. PHP Convert datetime format.