1 <?php
defined('SYSPATH') or die('No direct access allowed.');
3 * Help with formatting datestamps
7 private static function _nice_format_duration($start_time, $end_time) {
8 $duration = $end_time - $start_time;
9 $days = $duration / 86400;
10 $hours = ($duration %
86400) / 3600;
11 $minutes = ($duration %
3600) / 60;
12 $seconds = ($duration %
60);
13 return sprintf("%s: %dd %dh %dm %ds", _("Duration"),
14 $days, $hours, $minutes, $seconds);
18 * Outputs a nicely formatted version of "2003-03-12 21:14:34 to 2003-03-12 21:14:35<br>
19 * Duration: 0d 0h 0m 1s"
21 * @param $start_time int timestamp
22 * @param $end_time int timestamp
24 public static function duration($start_time, $end_time)
27 $duration = date($fmt, $start_time) . " to " .
28 date($fmt, $end_time) . "<br />\n";
30 $duration .= self
::_nice_format_duration($start_time, $end_time)."\n";
35 * Return array of abbrivated weekday names
36 * NOTE: Are you Really Sure you need this?
38 static function abbr_day_names()
52 * Return array of abbrivated month names
53 * NOTE: Are you Really Sure you need this?
55 static function abbr_month_names()
74 * Return array of full weekday names
75 * NOTE: Are you Really Sure you need this?
77 static function day_names()
91 * Return array of full month names
92 * NOTE: Are you Really Sure you need this?
94 static function month_names()
115 * @param $timezone string = null, defaults to php.ini's value
116 * @return int seconds
118 static function utc_offset($timezone = null) {
120 $timezone = date_default_timezone_get();
122 if($timezone == 'UTC') {
125 $utc = new DateTimeZone('UTC');
126 $remote_dtz = new DateTimeZone($timezone);
128 $origin_dt = new DateTime("now", $utc);
129 $remote_dt = new DateTime("now", $remote_dtz);
131 return $remote_dtz->getOffset($remote_dt);