Skip to content

Instantly share code, notes, and snippets.

@rajankur
Last active August 29, 2015 14:14
Show Gist options
  • Save rajankur/88dfb39bf7805dddd487 to your computer and use it in GitHub Desktop.
Save rajankur/88dfb39bf7805dddd487 to your computer and use it in GitHub Desktop.
PHP: custom date time format
<?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