Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

feature request to date range array #619

Closed
wants to merge 4 commits into from
This page is out of date. Refresh to see the latest.
Showing with 36 additions and 0 deletions.
  1. +36 −0 system/helpers/date_helper.php
36 system/helpers/date_helper.php
View
@@ -695,5 +695,41 @@ function timezones($tz = '')
}
}
+// ------------------------------------------------------------------------
+
+/**
+ * Date Interval
+ *
+ * Returns an array of dates ordered by past date
+ * to future date.
+ *
+ * @access public
+ * @param string date_start
+ * @param string date_end
+ * @param int interval
+ * @param string date_format
+ * @return array
+ */
+if ( ! function_exists('date_interval'))
+{
+ public function date_interval($date_start, $date_end, $interval = 86400 ,$date_format = 'Y-m-d')
+ {
+ $result = array();
+
+ $date_start = strtotime($date_start);
+ $date_end = strtotime($date_end);
+
+ $larger = ($date_start > $date_end) ? $date_start : $date_end;
+ $smaller = ($date_start < $date_end) ? $date_start : $date_end;
+
+ while ($smaller <= $larger)
+ {
+ $result[] = date($date_format, $smaller);
+ $smaller += $interval;
+ }
+ return $result;
+ }
+}
+
/* End of file date_helper.php */
/* Location: ./system/helpers/date_helper.php */
Something went wrong with that request. Please try again.