blob: 6bc6c2b05a63f9eaf13cece816807ac7df3d3102 [file] [log] [blame]
Derek Jones8ede1a22011-10-05 13:34:52 -05001###########
2Date Helper
3###########
4
5The Date Helper file contains functions that help you work with dates.
6
Derek Jonesa4db4322013-07-20 08:59:59 -07007.. contents::
8 :local:
9
10.. raw:: html
11
12 <div class="custom-index container"></div>
Derek Jones8ede1a22011-10-05 13:34:52 -050013
14Loading this Helper
15===================
16
Andrey Andreev48a86752012-11-08 15:16:34 +020017This helper is loaded using the following code::
Derek Jones8ede1a22011-10-05 13:34:52 -050018
19 $this->load->helper('date');
20
Derek Jonesa4db4322013-07-20 08:59:59 -070021Available Functions
22===================
23
Derek Jones8ede1a22011-10-05 13:34:52 -050024The following functions are available:
25
Derek Jones8ede1a22011-10-05 13:34:52 -050026
Andrey Andreevcd3d9db2015-02-02 13:41:01 +020027.. php:function:: now([$timezone = NULL])
Derek Jones8ede1a22011-10-05 13:34:52 -050028
Andrey Andreev48a86752012-11-08 15:16:34 +020029 :param string $timezone: Timezone
Andrey Andreev3de130c2014-02-07 23:31:49 +020030 :returns: UNIX timestamp
31 :rtype: int
Iban Eguia7bf0a4f2012-03-27 18:36:15 +020032
Derek Jonesa4db4322013-07-20 08:59:59 -070033 Returns the current time as a UNIX timestamp, referenced either to your server's
Andrey Andreev71d8f722017-01-17 12:01:00 +020034 local time or any PHP supported timezone, based on the "time reference" setting
Derek Jonesa4db4322013-07-20 08:59:59 -070035 in your config file. If you do not intend to set your master time reference to
36 any other PHP supported timezone (which you'll typically do if you run a site
37 that lets each user set their own timezone settings) there is no benefit to using
38 this function over PHP's ``time()`` function.
Derek Jonesa4db4322013-07-20 08:59:59 -070039 ::
Iban Eguia7bf0a4f2012-03-27 18:36:15 +020040
Derek Jonesa4db4322013-07-20 08:59:59 -070041 echo now('Australia/Victoria');
Andrey Andreev48a86752012-11-08 15:16:34 +020042
Derek Jonesa4db4322013-07-20 08:59:59 -070043 If a timezone is not provided, it will return ``time()`` based on the
44 **time_reference** setting.
Derek Jones8ede1a22011-10-05 13:34:52 -050045
Andrey Andreevcd3d9db2015-02-02 13:41:01 +020046.. php:function:: mdate([$datestr = ''[, $time = '']])
Andrey Andreev48a86752012-11-08 15:16:34 +020047
Andrey Andreev3de130c2014-02-07 23:31:49 +020048 :param string $datestr: Date string
49 :param int $time: UNIX timestamp
50 :returns: MySQL-formatted date
51 :rtype: string
Andrey Andreev48a86752012-11-08 15:16:34 +020052
Master Yodabd2a7e42015-03-25 02:36:31 -070053 This function is identical to PHP's `date() <http://php.net/manual/en/function.date.php>`_
Derek Jonesa4db4322013-07-20 08:59:59 -070054 function, except that it lets you use MySQL style date codes, where each
55 code letter is preceded with a percent sign, e.g. `%Y %m %d`
Derek Jones8ede1a22011-10-05 13:34:52 -050056
Derek Jonesa4db4322013-07-20 08:59:59 -070057 The benefit of doing dates this way is that you don't have to worry
58 about escaping any characters that are not date codes, as you would
59 normally have to do with the ``date()`` function.
Derek Jones8ede1a22011-10-05 13:34:52 -050060
Derek Jonesa4db4322013-07-20 08:59:59 -070061 Example::
Derek Jones8ede1a22011-10-05 13:34:52 -050062
Derek Jonesa4db4322013-07-20 08:59:59 -070063 $datestring = 'Year: %Y Month: %m Day: %d - %h:%i %a';
64 $time = time();
65 echo mdate($datestring, $time);
Derek Jones8ede1a22011-10-05 13:34:52 -050066
Derek Jonesa4db4322013-07-20 08:59:59 -070067 If a timestamp is not included in the second parameter the current time
68 will be used.
Derek Jones8ede1a22011-10-05 13:34:52 -050069
Andrey Andreevcd3d9db2015-02-02 13:41:01 +020070.. php:function:: standard_date([$fmt = 'DATE_RFC822'[, $time = NULL]])
Andrey Andreev48a86752012-11-08 15:16:34 +020071
72 :param string $fmt: Date format
Andrey Andreev3de130c2014-02-07 23:31:49 +020073 :param int $time: UNIX timestamp
74 :returns: Formatted date or FALSE on invalid format
75 :rtype: string
Andrey Andreev48a86752012-11-08 15:16:34 +020076
Derek Jonesa4db4322013-07-20 08:59:59 -070077 Lets you generate a date string in one of several standardized formats.
Derek Jones8ede1a22011-10-05 13:34:52 -050078
Derek Jonesa4db4322013-07-20 08:59:59 -070079 Example::
Derek Jones8ede1a22011-10-05 13:34:52 -050080
Derek Jonesa4db4322013-07-20 08:59:59 -070081 $format = 'DATE_RFC822';
82 $time = time();
83 echo standard_date($format, $time);
Derek Jones8ede1a22011-10-05 13:34:52 -050084
Andrey Andreev8b9dd222014-01-24 14:41:22 +020085 .. note:: This function is DEPRECATED. Use the native ``date()`` combined with
Derek Jonesa4db4322013-07-20 08:59:59 -070086 `DateTime's format constants
Andrey Andreev610be9d2016-11-23 13:40:16 +020087 <https://secure.php.net/manual/en/class.datetime.php#datetime.constants.types>`_
Derek Jonesa4db4322013-07-20 08:59:59 -070088 instead::
Andrey Andreevac570332012-07-04 13:04:10 +030089
Derek Jonesa4db4322013-07-20 08:59:59 -070090 echo date(DATE_RFC822, time());
Andrey Andreevac570332012-07-04 13:04:10 +030091
Derek Jonesa4db4322013-07-20 08:59:59 -070092 **Supported formats:**
Derek Jones8ede1a22011-10-05 13:34:52 -050093
Derek Jonesa4db4322013-07-20 08:59:59 -070094 =============== ======================= ======================================
Andrey Andreev3de130c2014-02-07 23:31:49 +020095 Constant Description Example
Derek Jonesa4db4322013-07-20 08:59:59 -070096 =============== ======================= ======================================
Andrey Andreev3de130c2014-02-07 23:31:49 +020097 DATE_ATOM Atom 2005-08-15T16:13:03+0000
98 DATE_COOKIE HTTP Cookies Sun, 14 Aug 2005 16:13:03 UTC
99 DATE_ISO8601 ISO-8601 2005-08-14T16:13:03+00:00
100 DATE_RFC822 RFC 822 Sun, 14 Aug 05 16:13:03 UTC
101 DATE_RFC850 RFC 850 Sunday, 14-Aug-05 16:13:03 UTC
102 DATE_RFC1036 RFC 1036 Sunday, 14-Aug-05 16:13:03 UTC
103 DATE_RFC1123 RFC 1123 Sun, 14 Aug 2005 16:13:03 UTC
104 DATE_RFC2822 RFC 2822 Sun, 14 Aug 2005 16:13:03 +0000
105 DATE_RSS RSS Sun, 14 Aug 2005 16:13:03 UTC
106 DATE_W3C W3C 2005-08-14T16:13:03+0000
Derek Jonesa4db4322013-07-20 08:59:59 -0700107 =============== ======================= ======================================
Derek Jones8ede1a22011-10-05 13:34:52 -0500108
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200109.. php:function:: local_to_gmt([$time = ''])
Derek Jones8ede1a22011-10-05 13:34:52 -0500110
Andrey Andreev48a86752012-11-08 15:16:34 +0200111 :param int $time: UNIX timestamp
Andrey Andreev3de130c2014-02-07 23:31:49 +0200112 :returns: UNIX timestamp
113 :rtype: int
Derek Jones8ede1a22011-10-05 13:34:52 -0500114
Derek Jonesa4db4322013-07-20 08:59:59 -0700115 Takes a UNIX timestamp as input and returns it as GMT.
Derek Jones8ede1a22011-10-05 13:34:52 -0500116
Derek Jonesa4db4322013-07-20 08:59:59 -0700117 Example::
Derek Jones8ede1a22011-10-05 13:34:52 -0500118
Derek Jonesa4db4322013-07-20 08:59:59 -0700119 $gmt = local_to_gmt(time());
Derek Jones8ede1a22011-10-05 13:34:52 -0500120
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200121.. php:function:: gmt_to_local([$time = ''[, $timezone = 'UTC'[, $dst = FALSE]]])
Andrey Andreev48a86752012-11-08 15:16:34 +0200122
Andrey Andreev3de130c2014-02-07 23:31:49 +0200123 :param int $time: UNIX timestamp
Andrey Andreev48a86752012-11-08 15:16:34 +0200124 :param string $timezone: Timezone
Andrey Andreev3de130c2014-02-07 23:31:49 +0200125 :param bool $dst: Whether DST is active
126 :returns: UNIX timestamp
127 :rtype: int
Andrey Andreev48a86752012-11-08 15:16:34 +0200128
Derek Jonesa4db4322013-07-20 08:59:59 -0700129 Takes a UNIX timestamp (referenced to GMT) as input, and converts it to
130 a localized timestamp based on the timezone and Daylight Saving Time
131 submitted.
Derek Jones8ede1a22011-10-05 13:34:52 -0500132
Derek Jonesa4db4322013-07-20 08:59:59 -0700133 Example::
Derek Jones8ede1a22011-10-05 13:34:52 -0500134
Derek Jonesa4db4322013-07-20 08:59:59 -0700135 $timestamp = 1140153693;
136 $timezone = 'UM8';
137 $daylight_saving = TRUE;
138 echo gmt_to_local($timestamp, $timezone, $daylight_saving);
Derek Jones8ede1a22011-10-05 13:34:52 -0500139
140
Derek Jonesa4db4322013-07-20 08:59:59 -0700141 .. note:: For a list of timezones see the reference at the bottom of this page.
Derek Jones8ede1a22011-10-05 13:34:52 -0500142
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200143.. php:function:: mysql_to_unix([$time = ''])
Derek Jones8ede1a22011-10-05 13:34:52 -0500144
Andrey Andreev3de130c2014-02-07 23:31:49 +0200145 :param string $time: MySQL timestamp
146 :returns: UNIX timestamp
147 :rtype: int
Derek Jones8ede1a22011-10-05 13:34:52 -0500148
Derek Jonesa4db4322013-07-20 08:59:59 -0700149 Takes a MySQL Timestamp as input and returns it as a UNIX timestamp.
Derek Jones8ede1a22011-10-05 13:34:52 -0500150
Derek Jonesa4db4322013-07-20 08:59:59 -0700151 Example::
Derek Jones8ede1a22011-10-05 13:34:52 -0500152
Derek Jonesa4db4322013-07-20 08:59:59 -0700153 $unix = mysql_to_unix('20061124092345');
Derek Jones8ede1a22011-10-05 13:34:52 -0500154
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200155.. php:function:: unix_to_human([$time = ''[, $seconds = FALSE[, $fmt = 'us']]])
Derek Jones8ede1a22011-10-05 13:34:52 -0500156
Andrey Andreev48a86752012-11-08 15:16:34 +0200157 :param int $time: UNIX timestamp
158 :param bool $seconds: Whether to show seconds
159 :param string $fmt: format (us or euro)
Andrey Andreev3de130c2014-02-07 23:31:49 +0200160 :returns: Formatted date
161 :rtype: string
Derek Jones8ede1a22011-10-05 13:34:52 -0500162
Derek Jonesa4db4322013-07-20 08:59:59 -0700163 Takes a UNIX timestamp as input and returns it in a human readable
164 format with this prototype::
Derek Jones8ede1a22011-10-05 13:34:52 -0500165
Derek Jonesa4db4322013-07-20 08:59:59 -0700166 YYYY-MM-DD HH:MM:SS AM/PM
Derek Jones8ede1a22011-10-05 13:34:52 -0500167
Derek Jonesa4db4322013-07-20 08:59:59 -0700168 This can be useful if you need to display a date in a form field for
169 submission.
Derek Jones8ede1a22011-10-05 13:34:52 -0500170
Derek Jonesa4db4322013-07-20 08:59:59 -0700171 The time can be formatted with or without seconds, and it can be set to
172 European or US format. If only the timestamp is submitted it will return
173 the time without seconds formatted for the U.S.
Derek Jones8ede1a22011-10-05 13:34:52 -0500174
Derek Jonesa4db4322013-07-20 08:59:59 -0700175 Examples::
Derek Jones8ede1a22011-10-05 13:34:52 -0500176
Derek Jonesa4db4322013-07-20 08:59:59 -0700177 $now = time();
178 echo unix_to_human($now); // U.S. time, no seconds
179 echo unix_to_human($now, TRUE, 'us'); // U.S. time with seconds
180 echo unix_to_human($now, TRUE, 'eu'); // Euro time with seconds
Derek Jones8ede1a22011-10-05 13:34:52 -0500181
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200182.. php:function:: human_to_unix([$datestr = ''])
Andrey Andreev48a86752012-11-08 15:16:34 +0200183
Andrey Andreev3de130c2014-02-07 23:31:49 +0200184 :param int $datestr: Date string
185 :returns: UNIX timestamp or FALSE on failure
186 :rtype: int
Andrey Andreev48a86752012-11-08 15:16:34 +0200187
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200188 The opposite of the :php:func:`unix_to_time()` function. Takes a "human"
Derek Jonesa4db4322013-07-20 08:59:59 -0700189 time as input and returns it as a UNIX timestamp. This is useful if you
190 accept "human" formatted dates submitted via a form. Returns boolean FALSE
191 date string passed to it is not formatted as indicated above.
Derek Jones8ede1a22011-10-05 13:34:52 -0500192
Derek Jonesa4db4322013-07-20 08:59:59 -0700193 Example::
Derek Jones8ede1a22011-10-05 13:34:52 -0500194
Derek Jonesa4db4322013-07-20 08:59:59 -0700195 $now = time();
196 $human = unix_to_human($now);
197 $unix = human_to_unix($human);
Derek Jones8ede1a22011-10-05 13:34:52 -0500198
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200199.. php:function:: nice_date([$bad_date = ''[, $format = FALSE]])
Andrey Andreev48a86752012-11-08 15:16:34 +0200200
201 :param int $bad_date: The terribly formatted date-like string
202 :param string $format: Date format to return (same as PHP's ``date()`` function)
Andrey Andreev3de130c2014-02-07 23:31:49 +0200203 :returns: Formatted date
204 :rtype: string
Andrey Andreev48a86752012-11-08 15:16:34 +0200205
Derek Jonesa4db4322013-07-20 08:59:59 -0700206 This function can take a number poorly-formed date formats and convert
207 them into something useful. It also accepts well-formed dates.
Derek Jones8ede1a22011-10-05 13:34:52 -0500208
Derek Jonesa4db4322013-07-20 08:59:59 -0700209 The function will return a UNIX timestamp by default. You can, optionally,
210 pass a format string (the same type as the PHP ``date()`` function accepts)
211 as the second parameter.
Derek Jones8ede1a22011-10-05 13:34:52 -0500212
Derek Jonesa4db4322013-07-20 08:59:59 -0700213 Example::
Derek Jones8ede1a22011-10-05 13:34:52 -0500214
Derek Jonesa4db4322013-07-20 08:59:59 -0700215 $bad_date = '199605';
216 // Should Produce: 1996-05-01
217 $better_date = nice_date($bad_date, 'Y-m-d');
Andrey Andreevc275b232012-06-15 16:13:17 +0300218
Derek Jonesa4db4322013-07-20 08:59:59 -0700219 $bad_date = '9-11-2001';
220 // Should Produce: 2001-09-11
221 $better_date = nice_date($bad_date, 'Y-m-d');
Derek Jones8ede1a22011-10-05 13:34:52 -0500222
Andrey Andreev610be9d2016-11-23 13:40:16 +0200223 .. note:: This function is DEPRECATED. Use PHP's native `DateTime class
224 <https://secure.php.net/datetime>`_ instead.
225
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200226.. php:function:: timespan([$seconds = 1[, $time = ''[, $units = '']]])
Andrey Andreev48a86752012-11-08 15:16:34 +0200227
228 :param int $seconds: Number of seconds
229 :param string $time: UNIX timestamp
230 :param int $units: Number of time units to display
Andrey Andreev3de130c2014-02-07 23:31:49 +0200231 :returns: Formatted time difference
232 :rtype: string
Andrey Andreev48a86752012-11-08 15:16:34 +0200233
Derek Jonesa4db4322013-07-20 08:59:59 -0700234 Formats a UNIX timestamp so that is appears similar to this::
Derek Jones8ede1a22011-10-05 13:34:52 -0500235
Derek Jonesa4db4322013-07-20 08:59:59 -0700236 1 Year, 10 Months, 2 Weeks, 5 Days, 10 Hours, 16 Minutes
Derek Jones8ede1a22011-10-05 13:34:52 -0500237
Derek Jonesa4db4322013-07-20 08:59:59 -0700238 The first parameter must contain a UNIX timestamp.
239 The second parameter must contain a timestamp that is greater that the
240 first timestamp.
241 The thirdparameter is optional and limits the number of time units to display.
Andrey Andreev48a86752012-11-08 15:16:34 +0200242
Derek Jonesa4db4322013-07-20 08:59:59 -0700243 If the second parameter empty, the current time will be used.
Andrey Andreev48a86752012-11-08 15:16:34 +0200244
Derek Jonesa4db4322013-07-20 08:59:59 -0700245 The most common purpose for this function is to show how much time has
246 elapsed from some point in time in the past to now.
Derek Jones8ede1a22011-10-05 13:34:52 -0500247
Derek Jonesa4db4322013-07-20 08:59:59 -0700248 Example::
Derek Jones8ede1a22011-10-05 13:34:52 -0500249
Derek Jonesa4db4322013-07-20 08:59:59 -0700250 $post_date = '1079621429';
251 $now = time();
252 $units = 2;
253 echo timespan($post_date, $now, $units);
Derek Jones8ede1a22011-10-05 13:34:52 -0500254
Derek Jonesa4db4322013-07-20 08:59:59 -0700255 .. note:: The text generated by this function is found in the following language
256 file: `language/<your_lang>/date_lang.php`
Derek Jones8ede1a22011-10-05 13:34:52 -0500257
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200258.. php:function:: days_in_month([$month = 0[, $year = '']])
Andrey Andreev48a86752012-11-08 15:16:34 +0200259
260 :param int $month: a numeric month
261 :param int $year: a numeric year
Andrey Andreev3de130c2014-02-07 23:31:49 +0200262 :returns: Count of days in the specified month
263 :rtype: int
Andrey Andreev48a86752012-11-08 15:16:34 +0200264
Derek Jonesa4db4322013-07-20 08:59:59 -0700265 Returns the number of days in a given month/year. Takes leap years into
266 account.
Derek Jones8ede1a22011-10-05 13:34:52 -0500267
Derek Jonesa4db4322013-07-20 08:59:59 -0700268 Example::
Derek Jones8ede1a22011-10-05 13:34:52 -0500269
Derek Jonesa4db4322013-07-20 08:59:59 -0700270 echo days_in_month(06, 2005);
Derek Jones8ede1a22011-10-05 13:34:52 -0500271
Derek Jonesa4db4322013-07-20 08:59:59 -0700272 If the second parameter is empty, the current year will be used.
Derek Jones8ede1a22011-10-05 13:34:52 -0500273
Andrey Andreevbe368a82014-02-20 15:46:05 +0200274 .. note:: This function will alias the native ``cal_days_in_month()``, if
275 it is available.
276
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200277.. php:function:: date_range([$unix_start = ''[, $mixed = ''[, $is_unix = TRUE[, $format = 'Y-m-d']]]])
Andrey Andreev48a86752012-11-08 15:16:34 +0200278
279 :param int $unix_start: UNIX timestamp of the range start date
280 :param int $mixed: UNIX timestamp of the range end date or interval in days
281 :param bool $is_unix: set to FALSE if $mixed is not a timestamp
282 :param string $format: Output date format, same as in ``date()``
Andrey Andreev3de130c2014-02-07 23:31:49 +0200283 :returns: An array of dates
284 :rtype: array
Andrey Andreev48a86752012-11-08 15:16:34 +0200285
Derek Jonesa4db4322013-07-20 08:59:59 -0700286 Returns a list of dates within a specified period.
Andrey Andreev2139ecd2012-01-11 23:58:50 +0200287
Derek Jonesa4db4322013-07-20 08:59:59 -0700288 Example::
Andrey Andreev2139ecd2012-01-11 23:58:50 +0200289
Derek Jonesa4db4322013-07-20 08:59:59 -0700290 $range = date_range('2012-01-01', '2012-01-15');
291 echo "First 15 days of 2012:";
292 foreach ($range as $date)
293 {
294 echo $date."\n";
295 }
Andrey Andreev2139ecd2012-01-11 23:58:50 +0200296
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200297.. php:function:: timezones([$tz = ''])
Andrey Andreev48a86752012-11-08 15:16:34 +0200298
Andrey Andreev3de130c2014-02-07 23:31:49 +0200299 :param string $tz: A numeric timezone
300 :returns: Hour difference from UTC
301 :rtype: int
Andrey Andreev48a86752012-11-08 15:16:34 +0200302
Derek Jonesa4db4322013-07-20 08:59:59 -0700303 Takes a timezone reference (for a list of valid timezones, see the
304 "Timezone Reference" below) and returns the number of hours offset from
305 UTC.
Derek Jones8ede1a22011-10-05 13:34:52 -0500306
Derek Jonesa4db4322013-07-20 08:59:59 -0700307 Example::
Derek Jones8ede1a22011-10-05 13:34:52 -0500308
Derek Jonesa4db4322013-07-20 08:59:59 -0700309 echo timezones('UM5');
Derek Jones8ede1a22011-10-05 13:34:52 -0500310
311
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200312 This function is useful when used with :php:func:`timezone_menu()`.
Derek Jones8ede1a22011-10-05 13:34:52 -0500313
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200314.. php:function:: timezone_menu([$default = 'UTC'[, $class = ''[, $name = 'timezones'[, $attributes = '']]]])
Derek Jones8ede1a22011-10-05 13:34:52 -0500315
Andrey Andreev48a86752012-11-08 15:16:34 +0200316 :param string $default: Timezone
317 :param string $class: Class name
318 :param string $name: Menu name
319 :param mixed $attributes: HTML attributes
Andrey Andreev3de130c2014-02-07 23:31:49 +0200320 :returns: HTML drop down menu with time zones
321 :rtype: string
Andrey Andreev48a86752012-11-08 15:16:34 +0200322
Derek Jonesa4db4322013-07-20 08:59:59 -0700323 Generates a pull-down menu of timezones, like this one:
Derek Jones8ede1a22011-10-05 13:34:52 -0500324
Derek Jonesa4db4322013-07-20 08:59:59 -0700325 .. raw:: html
Derek Jones8ede1a22011-10-05 13:34:52 -0500326
Derek Jonesa4db4322013-07-20 08:59:59 -0700327 <form action="#">
328 <select name="timezones">
329 <option value='UM12'>(UTC -12:00) Baker/Howland Island</option>
330 <option value='UM11'>(UTC -11:00) Samoa Time Zone, Niue</option>
331 <option value='UM10'>(UTC -10:00) Hawaii-Aleutian Standard Time, Cook Islands, Tahiti</option>
332 <option value='UM95'>(UTC -9:30) Marquesas Islands</option>
333 <option value='UM9'>(UTC -9:00) Alaska Standard Time, Gambier Islands</option>
334 <option value='UM8'>(UTC -8:00) Pacific Standard Time, Clipperton Island</option>
335 <option value='UM7'>(UTC -7:00) Mountain Standard Time</option>
336 <option value='UM6'>(UTC -6:00) Central Standard Time</option>
337 <option value='UM5'>(UTC -5:00) Eastern Standard Time, Western Caribbean Standard Time</option>
338 <option value='UM45'>(UTC -4:30) Venezuelan Standard Time</option>
339 <option value='UM4'>(UTC -4:00) Atlantic Standard Time, Eastern Caribbean Standard Time</option>
340 <option value='UM35'>(UTC -3:30) Newfoundland Standard Time</option>
341 <option value='UM3'>(UTC -3:00) Argentina, Brazil, French Guiana, Uruguay</option>
342 <option value='UM2'>(UTC -2:00) South Georgia/South Sandwich Islands</option>
343 <option value='UM1'>(UTC -1:00) Azores, Cape Verde Islands</option>
344 <option value='UTC' selected='selected'>(UTC) Greenwich Mean Time, Western European Time</option>
345 <option value='UP1'>(UTC +1:00) Central European Time, West Africa Time</option>
346 <option value='UP2'>(UTC +2:00) Central Africa Time, Eastern European Time, Kaliningrad Time</option>
347 <option value='UP3'>(UTC +3:00) Moscow Time, East Africa Time</option>
348 <option value='UP35'>(UTC +3:30) Iran Standard Time</option>
349 <option value='UP4'>(UTC +4:00) Azerbaijan Standard Time, Samara Time</option>
350 <option value='UP45'>(UTC +4:30) Afghanistan</option>
351 <option value='UP5'>(UTC +5:00) Pakistan Standard Time, Yekaterinburg Time</option>
352 <option value='UP55'>(UTC +5:30) Indian Standard Time, Sri Lanka Time</option>
353 <option value='UP575'>(UTC +5:45) Nepal Time</option>
354 <option value='UP6'>(UTC +6:00) Bangladesh Standard Time, Bhutan Time, Omsk Time</option>
355 <option value='UP65'>(UTC +6:30) Cocos Islands, Myanmar</option>
356 <option value='UP7'>(UTC +7:00) Krasnoyarsk Time, Cambodia, Laos, Thailand, Vietnam</option>
357 <option value='UP8'>(UTC +8:00) Australian Western Standard Time, Beijing Time, Irkutsk Time</option>
358 <option value='UP875'>(UTC +8:45) Australian Central Western Standard Time</option>
359 <option value='UP9'>(UTC +9:00) Japan Standard Time, Korea Standard Time, Yakutsk Time</option>
360 <option value='UP95'>(UTC +9:30) Australian Central Standard Time</option>
361 <option value='UP10'>(UTC +10:00) Australian Eastern Standard Time, Vladivostok Time</option>
362 <option value='UP105'>(UTC +10:30) Lord Howe Island</option>
Peter Denk0ef898b2015-01-06 16:03:17 +0100363 <option value='UP11'>(UTC +11:00) Srednekolymsk Time, Solomon Islands, Vanuatu</option>
Derek Jonesa4db4322013-07-20 08:59:59 -0700364 <option value='UP115'>(UTC +11:30) Norfolk Island</option>
365 <option value='UP12'>(UTC +12:00) Fiji, Gilbert Islands, Kamchatka Time, New Zealand Standard Time</option>
366 <option value='UP1275'>(UTC +12:45) Chatham Islands Standard Time</option>
367 <option value='UP13'>(UTC +13:00) Phoenix Islands Time, Tonga</option>
368 <option value='UP14'>(UTC +14:00) Line Islands</option>
369 </select>
370 </form>
Derek Jones8ede1a22011-10-05 13:34:52 -0500371
372
Derek Jonesa4db4322013-07-20 08:59:59 -0700373 This menu is useful if you run a membership site in which your users are
374 allowed to set their local timezone value.
Derek Jones8ede1a22011-10-05 13:34:52 -0500375
Derek Jonesa4db4322013-07-20 08:59:59 -0700376 The first parameter lets you set the "selected" state of the menu. For
377 example, to set Pacific time as the default you will do this::
Derek Jones8ede1a22011-10-05 13:34:52 -0500378
Derek Jonesa4db4322013-07-20 08:59:59 -0700379 echo timezone_menu('UM8');
Derek Jones8ede1a22011-10-05 13:34:52 -0500380
Derek Jonesa4db4322013-07-20 08:59:59 -0700381 Please see the timezone reference below to see the values of this menu.
Derek Jones8ede1a22011-10-05 13:34:52 -0500382
Derek Jonesa4db4322013-07-20 08:59:59 -0700383 The second parameter lets you set a CSS class name for the menu.
Derek Jones8ede1a22011-10-05 13:34:52 -0500384
Derek Jonesa4db4322013-07-20 08:59:59 -0700385 The fourth parameter lets you set one or more attributes on the generated select tag.
Mat Whitney7540ded2012-06-22 12:02:10 -0700386
Derek Jonesa4db4322013-07-20 08:59:59 -0700387 .. note:: The text contained in the menu is found in the following
388 language file: `language/<your_lang>/date_lang.php`
Derek Jones8ede1a22011-10-05 13:34:52 -0500389
Derek Jones8ede1a22011-10-05 13:34:52 -0500390Timezone Reference
391==================
392
393The following table indicates each timezone and its location.
394
Kwaan Onlinee90b6842012-01-31 10:15:30 +0000395Note some of the location lists have been abridged for clarity and formatting.
396
Andrey Andreev3de130c2014-02-07 23:31:49 +0200397=========== =====================================================================
398Time Zone Location
399=========== =====================================================================
400UM12 (UTC - 12:00) Baker/Howland Island
401UM11 (UTC - 11:00) Samoa Time Zone, Niue
402UM10 (UTC - 10:00) Hawaii-Aleutian Standard Time, Cook Islands
403UM95 (UTC - 09:30) Marquesas Islands
404UM9 (UTC - 09:00) Alaska Standard Time, Gambier Islands
405UM8 (UTC - 08:00) Pacific Standard Time, Clipperton Island
Andrey Andreev8cb6f362015-05-02 16:35:51 +0300406UM7 (UTC - 07:00) Mountain Standard Time
Andrey Andreev3de130c2014-02-07 23:31:49 +0200407UM6 (UTC - 06:00) Central Standard Time
408UM5 (UTC - 05:00) Eastern Standard Time, Western Caribbean
409UM45 (UTC - 04:30) Venezuelan Standard Time
410UM4 (UTC - 04:00) Atlantic Standard Time, Eastern Caribbean
411UM35 (UTC - 03:30) Newfoundland Standard Time
412UM3 (UTC - 03:00) Argentina, Brazil, French Guiana, Uruguay
413UM2 (UTC - 02:00) South Georgia/South Sandwich Islands
414UM1 (UTC -1:00) Azores, Cape Verde Islands
415UTC (UTC) Greenwich Mean Time, Western European Time
416UP1 (UTC +1:00) Central European Time, West Africa Time
417UP2 (UTC +2:00) Central Africa Time, Eastern European Time
418UP3 (UTC +3:00) Moscow Time, East Africa Time
419UP35 (UTC +3:30) Iran Standard Time
420UP4 (UTC +4:00) Azerbaijan Standard Time, Samara Time
421UP45 (UTC +4:30) Afghanistan
422UP5 (UTC +5:00) Pakistan Standard Time, Yekaterinburg Time
423UP55 (UTC +5:30) Indian Standard Time, Sri Lanka Time
424UP575 (UTC +5:45) Nepal Time
425UP6 (UTC +6:00) Bangladesh Standard Time, Bhutan Time, Omsk Time
426UP65 (UTC +6:30) Cocos Islands, Myanmar
427UP7 (UTC +7:00) Krasnoyarsk Time, Cambodia, Laos, Thailand, Vietnam
428UP8 (UTC +8:00) Australian Western Standard Time, Beijing Time
429UP875 (UTC +8:45) Australian Central Western Standard Time
430UP9 (UTC +9:00) Japan Standard Time, Korea Standard Time, Yakutsk
431UP95 (UTC +9:30) Australian Central Standard Time
432UP10 (UTC +10:00) Australian Eastern Standard Time, Vladivostok Time
433UP105 (UTC +10:30) Lord Howe Island
Peter Denk0ef898b2015-01-06 16:03:17 +0100434UP11 (UTC +11:00) Srednekolymsk Time, Solomon Islands, Vanuatu
Andrey Andreev3de130c2014-02-07 23:31:49 +0200435UP115 (UTC +11:30) Norfolk Island
436UP12 (UTC +12:00) Fiji, Gilbert Islands, Kamchatka, New Zealand
437UP1275 (UTC +12:45) Chatham Islands Standard Time
438UP13 (UTC +13:00) Phoenix Islands Time, Tonga
439UP14 (UTC +14:00) Line Islands
Andrey Andreev610be9d2016-11-23 13:40:16 +0200440=========== =====================================================================