Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Luach\Controller;
- use Zend\Mvc\Controller\ActionController,
- Zend\View\Model\ViewModel;
- class LuachController extends ActionController {
- public function indexAction() {
- $aDates = $this->createDateRangeArray('2012-09-01', '2013-09-01');
- foreach ($aDates as $aDate) {
- $aJulianFormat = $this->splitDate($aDate);
- // $aJulianFormat = array('month'=>date('m'), 'day'=>date('d'), 'year' => date('Y'));
- $jewishDate = jdtojewish(
- gregoriantojd($aJulianFormat['month'],
- $aJulianFormat['day'],
- $aJulianFormat['year']),
- true,
- CAL_JEWISH_ADD_GERESHAYIM +
- CAL_JEWISH_ADD_ALAFIM +
- CAL_JEWISH_ADD_ALAFIM_GERESH
- );
- echo('jdtojewish' . ' : ' . $jewishDate . '<br>');
- echo('iconv' . ' : ' . iconv('ISO-8859-8', 'UTF-8', $jewishDate) . '<br>');
- }
- }
- private function createDateRangeArray($strDateFrom, $strDateTo) {
- // takes two dates formatted as YYYY-MM-DD and creates an
- // inclusive array of the dates between the from and to dates.
- // could test validity of dates here but I'm already doing
- // that in the main script
- $aryRange = array();
- $iDateFrom = mktime(1, 0, 0, substr($strDateFrom, 5, 2), substr($strDateFrom, 8, 2), substr($strDateFrom, 0, 4));
- $iDateTo = mktime(1, 0, 0, substr($strDateTo, 5, 2), substr($strDateTo, 8, 2), substr($strDateTo, 0, 4));
- if ($iDateTo >= $iDateFrom) {
- array_push($aryRange, date('Y-m-d', $iDateFrom)); // first entry
- while ($iDateFrom < $iDateTo) {
- $iDateFrom+=86400; // add 24 hours
- array_push($aryRange, date('Y-m-d', $iDateFrom));
- }
- }
- return $aryRange;
- }
- private function splitDate($sDate) {
- return date_parse_from_format("Y-m-d", $sDate);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement