Last active
January 19, 2018 20:49
-
-
Save dorianneto/f594e949e183ce95276af85bca9493a8 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) { | |
$d = $date->format($format); | |
} elseif (is_numeric($date)) { | |
$d = date($format, $date); | |
} else { | |
$d = (string) $date; | |
} | |
return $d; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment