summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/date_helper.php38
1 files changed, 37 insertions, 1 deletions
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index ab3a31867..987658c2e 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -92,7 +92,43 @@ function mdate($datestr = '', $time = '')
// ------------------------------------------------------------------------
/**
- * Convert MySQL Style Datecodes
+ * Standard Date
+ *
+ * Returns a date formatted according to the submitted standard.
+ *
+ * @access public
+ * @param string the chosen format
+ * @param integer Unix timestamp
+ * @return string
+ */
+function standard_date($fmt = 'DATE_RFC822', $time = '')
+{
+ $formats = array(
+ 'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%Q',
+ 'DATE_COOKIE' => '%l, %d-%M-%y %H:%i:%s UTC',
+ 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%O',
+ 'DATE_RFC822' => '%D, %d %M %y %H:%i:%s %O',
+ 'DATE_RFC850' => '%l, %d-%M-%y %H:%m:%i UTC',
+ 'DATE_RFC1036' => '%D, %d %M %y %H:%i:%s %O',
+ 'DATE_RFC1123' => '%D, %d %M %Y %H:%i:%s %O',
+ 'DATE_RFC2822' => '%D, %d %M %Y %H:%i:%s %O',
+ 'DATE_RSS' => '%D, %d %M %Y %H:%i:%s %O',
+ 'DATE_W3C' => '%Y-%m-%dT%H:%i:%s%Q'
+ );
+
+ if ( ! isset($formats[$fmt]))
+ {
+ return FALSE;
+ }
+
+ return mdate($formats[$fmt], $time);
+}
+
+
+// ------------------------------------------------------------------------
+
+/**
+ * Timespan
*
* Returns a span of seconds in this format:
* 10 days 14 hours 36 minutes 47 seconds