summaryrefslogtreecommitdiffstats
path: root/system/helpers/date_helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/helpers/date_helper.php')
-rw-r--r--system/helpers/date_helper.php41
1 files changed, 26 insertions, 15 deletions
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index fc790c585..a45b3d7ac 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -117,26 +117,37 @@ if ( ! function_exists('standard_date'))
*
* Returns a date formatted according to the submitted standard.
*
+ * As of PHP 5.2, the DateTime extension provides constants that
+ * serve for the exact same purpose and are used with date().
+ * Due to that, this function is DEPRECATED and should be removed
+ * in CodeIgniter 3.1+.
+ *
+ * Here are two examples of how you should replace it:
+ *
+ * date(DATE_RFC822, now()); // default
+ * date(DATE_W3C, $time); // a different format and time
+ *
+ * Reference: http://www.php.net/manual/en/class.datetime.php#datetime.constants.types
+ *
+ * @deprecated
* @param string the chosen format
* @param int Unix timestamp
* @return string
*/
- function standard_date($fmt = 'DATE_RFC822', $time = '')
+ function standard_date($fmt = 'DATE_RFC822', $time = NULL)
{
- $formats = array(
- 'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%O',
- '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:%i:%s 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%O'
- );
-
- return isset($formats[$fmt]) ? mdate($formats[$fmt], $time) : FALSE;
+ if (empty($time))
+ {
+ $time = now();
+ }
+
+ // Procedural style pre-defined constants from the DateTime extension
+ if (strpos($fmt, 'DATE_') !== 0 OR defined($fmt) === FALSE)
+ {
+ return FALSE;
+ }
+
+ return date(constant($fmt), $time);
}
}