Zend_View_Helper_ConvertDate
1 2 3 4 56 7 8 9 1011 12 13 14 1516 17 18 19 2021 22 23 24 2526 27 | <?php /** * Zend View Helper Convert Date * * @author Niels Lange <info@semanticsamsterdam.nl> * @copyright semantics <info@semanticsamsterdam.nl> */ class Zend_View_Helper_ConvertDate extends Zend_View_Helper_Abstract { /** * Convert date * * Converts yyyy-mm-dd to dd-mm-yyyy resp. dd-mm-yyyy to yyyy-mm-dd * * @param string $date */ public function convertDate($date) { if (preg_match('/^(\d){4}(-)(\d){2}(-)(\d){2}$/', $date)) { return substr($date, 8, 2) . '-' . substr($date, 5, 2) . '-' . substr($date, 0, 4); } elseif (preg_match('/^(\d){2}(-)(\d){2}(-)(\d){4}$/', $date)) { return substr($date, 6, 4) . '-' . substr($date, 3, 2) . '-' . substr($date, 0, 2); } else { return null; } } } |
Comments
You must login before commenting on a snippet. If you do not have an account, please register.
Snippet description
Snippet details
- Created:
-
niels
- Edited:
-
niels
- Revision Id:
- 198
- Edit Message:
- Initial Release
- ZF Version
- 1.8.3
- Tags:
- Zend_View_Helper
- Comments:
- 0
- Views:
- 1576
- Points:
- 0 (0 votes)