Example #1
0
 private function provideSwitchCase()
 {
     $sql = "  CASE    ";
     for ($i = 1; $i <= 12; $i++) {
         $year = jDateTime::date('o', null, false);
         $start = jDateTime::toGregorian(jDateTime::date('o', null, false), $i, 1);
         $end = jDateTime::toGregorian($i == 12 ? $year + 1 : $year, $i == 12 ? 1 : $i + 1, 1);
         $sql .= " WHEN created_at BETWEEN '" . date("o-m-d", strtotime(implode('-', $start))) . "' AND '" . date("o-m-d", strtotime(implode('-', $end))) . "' THEN " . "'" . $i . "' ";
     }
     return $sql . ' END';
 }
 /**
  * Convert persian entered date to gregorian
  *
  * @param $publish_date
  * @return null|string
  */
 protected function convertDate($publish_date)
 {
     if (empty($publish_date)) {
         return null;
     }
     list($date, $time) = explode(' ', $publish_date);
     list($year, $month, $day) = explode('-', $date);
     return implode('-', jDateTime::toGregorian($year, $month, $day)) . ' ' . $time . ":00";
 }
Example #3
0
 public function gregorianArray($jYear, $jMonth, $jDay)
 {
     return jDateTime::toGregorian($jYear, $jMonth, $jDay);
 }