| 1 | <?php |
||
| 5 | class DateUtil |
||
| 6 | { |
||
| 7 | 4 | public static function getDefaultParams(\DateTime $dateTime = null, $noTime = false, $useTimezone = false) |
|
| 22 | |||
| 23 | /** |
||
| 24 | * Returns a formatted date string. |
||
| 25 | * |
||
| 26 | * @param \DateTime|null $dateTime The DateTime object |
||
| 27 | * @param bool $noTime Indicates if the time will be added |
||
| 28 | * @param bool $useTimezone |
||
| 29 | * @param bool $useUtc |
||
| 30 | * |
||
| 31 | * @return mixed |
||
| 32 | */ |
||
| 33 | 4 | public static function getDateString(\DateTime $dateTime = null, $noTime = false, $useTimezone = false, $useUtc = false) |
|
| 41 | |||
| 42 | /** |
||
| 43 | * Returns the date format that can be passed to DateTime::format(). |
||
| 44 | * |
||
| 45 | * @param bool $noTime Indicates if the time will be added |
||
| 46 | * @param bool $useTimezone |
||
| 47 | * @param bool $useUtc |
||
| 48 | * |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | 4 | public static function getDateFormat($noTime = false, $useTimezone = false, $useUtc = false) |
|
| 60 | } |
||
| 61 |
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: