Last active
January 19, 2018 20:49
-
-
Save dorianneto/363bebbb8352d857bc11a810126d7929 to your computer and use it in GitHub Desktop.
Post: Torne-se um ninja das funções com Early Return
This file contains hidden or 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 | |
public static function formatDate($date) | |
{ | |
$format = DateTime::ATOM; | |
if ($date instanceof DateTime) { | |
return $date->format($format); | |
} | |
if (is_numeric($date)) { | |
return date($format, $date); | |
} | |
return (string) $date; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment