Last active
August 29, 2015 14:14
-
-
Save rajankur/88dfb39bf7805dddd487 to your computer and use it in GitHub Desktop.
PHP: custom date time format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The function convert an input string to a date with desired format. | |
* @param string $date | |
* @param string $format | |
* @return datetime | |
*/ | |
function customDate($date,$format) | |
{ | |
if($date=="" || $date=="0000-00-00 00:00:00") | |
return 0; | |
return date_format(new DateTime($date),$format); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment