blob: bed3b32a2ee13186e485f1756a3169679840570b [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
34 local time or any PHP suported timezone, based on the "time reference" setting
35 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
Derek Jonesa4db4322013-07-20 08:59:59 -070053 This function is identical to PHP's `date() <http://www.php.net/date>`_
54 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
87 <http://www.php.net/manual/en/class.datetime.php#datetime.constants.types>`_
88 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 Andreevcd3d9db2015-02-02 13:41:01 +0200223.. php:function:: timespan([$seconds = 1[, $time = ''[, $units = '']]])
Andrey Andreev48a86752012-11-08 15:16:34 +0200224
225 :param int $seconds: Number of seconds
226 :param string $time: UNIX timestamp
227 :param int $units: Number of time units to display
Andrey Andreev3de130c2014-02-07 23:31:49 +0200228 :returns: Formatted time difference
229 :rtype: string
Andrey Andreev48a86752012-11-08 15:16:34 +0200230
Derek Jonesa4db4322013-07-20 08:59:59 -0700231 Formats a UNIX timestamp so that is appears similar to this::
Derek Jones8ede1a22011-10-05 13:34:52 -0500232
Derek Jonesa4db4322013-07-20 08:59:59 -0700233 1 Year, 10 Months, 2 Weeks, 5 Days, 10 Hours, 16 Minutes
Derek Jones8ede1a22011-10-05 13:34:52 -0500234
Derek Jonesa4db4322013-07-20 08:59:59 -0700235 The first parameter must contain a UNIX timestamp.
236 The second parameter must contain a timestamp that is greater that the
237 first timestamp.
238 The thirdparameter is optional and limits the number of time units to display.
Andrey Andreev48a86752012-11-08 15:16:34 +0200239
Derek Jonesa4db4322013-07-20 08:59:59 -0700240 If the second parameter empty, the current time will be used.
Andrey Andreev48a86752012-11-08 15:16:34 +0200241
Derek Jonesa4db4322013-07-20 08:59:59 -0700242 The most common purpose for this function is to show how much time has
243 elapsed from some point in time in the past to now.
Derek Jones8ede1a22011-10-05 13:34:52 -0500244
Derek Jonesa4db4322013-07-20 08:59:59 -0700245 Example::
Derek Jones8ede1a22011-10-05 13:34:52 -0500246
Derek Jonesa4db4322013-07-20 08:59:59 -0700247 $post_date = '1079621429';
248 $now = time();
249 $units = 2;
250 echo timespan($post_date, $now, $units);
Derek Jones8ede1a22011-10-05 13:34:52 -0500251
Derek Jonesa4db4322013-07-20 08:59:59 -0700252 .. note:: The text generated by this function is found in the following language
253 file: `language/<your_lang>/date_lang.php`
Derek Jones8ede1a22011-10-05 13:34:52 -0500254
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200255.. php:function:: days_in_month([$month = 0[, $year = '']])
Andrey Andreev48a86752012-11-08 15:16:34 +0200256
257 :param int $month: a numeric month
258 :param int $year: a numeric year
Andrey Andreev3de130c2014-02-07 23:31:49 +0200259 :returns: Count of days in the specified month
260 :rtype: int
Andrey Andreev48a86752012-11-08 15:16:34 +0200261
Derek Jonesa4db4322013-07-20 08:59:59 -0700262 Returns the number of days in a given month/year. Takes leap years into
263 account.
Derek Jones8ede1a22011-10-05 13:34:52 -0500264
Derek Jonesa4db4322013-07-20 08:59:59 -0700265 Example::
Derek Jones8ede1a22011-10-05 13:34:52 -0500266
Derek Jonesa4db4322013-07-20 08:59:59 -0700267 echo days_in_month(06, 2005);
Derek Jones8ede1a22011-10-05 13:34:52 -0500268
Derek Jonesa4db4322013-07-20 08:59:59 -0700269 If the second parameter is empty, the current year will be used.
Derek Jones8ede1a22011-10-05 13:34:52 -0500270
Andrey Andreevbe368a82014-02-20 15:46:05 +0200271 .. note:: This function will alias the native ``cal_days_in_month()``, if
272 it is available.
273
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200274.. php:function:: date_range([$unix_start = ''[, $mixed = ''[, $is_unix = TRUE[, $format = 'Y-m-d']]]])
Andrey Andreev48a86752012-11-08 15:16:34 +0200275
276 :param int $unix_start: UNIX timestamp of the range start date
277 :param int $mixed: UNIX timestamp of the range end date or interval in days
278 :param bool $is_unix: set to FALSE if $mixed is not a timestamp
279 :param string $format: Output date format, same as in ``date()``
Andrey Andreev3de130c2014-02-07 23:31:49 +0200280 :returns: An array of dates
281 :rtype: array
Andrey Andreev48a86752012-11-08 15:16:34 +0200282
Derek Jonesa4db4322013-07-20 08:59:59 -0700283 Returns a list of dates within a specified period.
Andrey Andreev2139ecd2012-01-11 23:58:50 +0200284
Derek Jonesa4db4322013-07-20 08:59:59 -0700285 Example::
Andrey Andreev2139ecd2012-01-11 23:58:50 +0200286
Derek Jonesa4db4322013-07-20 08:59:59 -0700287 $range = date_range('2012-01-01', '2012-01-15');
288 echo "First 15 days of 2012:";
289 foreach ($range as $date)
290 {
291 echo $date."\n";
292 }
Andrey Andreev2139ecd2012-01-11 23:58:50 +0200293
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200294.. php:function:: timezones([$tz = ''])
Andrey Andreev48a86752012-11-08 15:16:34 +0200295
Andrey Andreev3de130c2014-02-07 23:31:49 +0200296 :param string $tz: A numeric timezone
297 :returns: Hour difference from UTC
298 :rtype: int
Andrey Andreev48a86752012-11-08 15:16:34 +0200299
Derek Jonesa4db4322013-07-20 08:59:59 -0700300 Takes a timezone reference (for a list of valid timezones, see the
301 "Timezone Reference" below) and returns the number of hours offset from
302 UTC.
Derek Jones8ede1a22011-10-05 13:34:52 -0500303
Derek Jonesa4db4322013-07-20 08:59:59 -0700304 Example::
Derek Jones8ede1a22011-10-05 13:34:52 -0500305
Derek Jonesa4db4322013-07-20 08:59:59 -0700306 echo timezones('UM5');
Derek Jones8ede1a22011-10-05 13:34:52 -0500307
308
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200309 This function is useful when used with :php:func:`timezone_menu()`.
Derek Jones8ede1a22011-10-05 13:34:52 -0500310
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200311.. php:function:: timezone_menu([$default = 'UTC'[, $class = ''[, $name = 'timezones'[, $attributes = '']]]])
Derek Jones8ede1a22011-10-05 13:34:52 -0500312
Andrey Andreev48a86752012-11-08 15:16:34 +0200313 :param string $default: Timezone
314 :param string $class: Class name
315 :param string $name: Menu name
316 :param mixed $attributes: HTML attributes
Andrey Andreev3de130c2014-02-07 23:31:49 +0200317 :returns: HTML drop down menu with time zones
318 :rtype: string
Andrey Andreev48a86752012-11-08 15:16:34 +0200319
Derek Jonesa4db4322013-07-20 08:59:59 -0700320 Generates a pull-down menu of timezones, like this one:
Derek Jones8ede1a22011-10-05 13:34:52 -0500321
Derek Jonesa4db4322013-07-20 08:59:59 -0700322 .. raw:: html
Derek Jones8ede1a22011-10-05 13:34:52 -0500323
Derek Jonesa4db4322013-07-20 08:59:59 -0700324 <form action="#">
325 <select name="timezones">
326 <option value='UM12'>(UTC -12:00) Baker/Howland Island</option>
327 <option value='UM11'>(UTC -11:00) Samoa Time Zone, Niue</option>
328 <option value='UM10'>(UTC -10:00) Hawaii-Aleutian Standard Time, Cook Islands, Tahiti</option>
329 <option value='UM95'>(UTC -9:30) Marquesas Islands</option>
330 <option value='UM9'>(UTC -9:00) Alaska Standard Time, Gambier Islands</option>
331 <option value='UM8'>(UTC -8:00) Pacific Standard Time, Clipperton Island</option>
332 <option value='UM7'>(UTC -7:00) Mountain Standard Time</option>
333 <option value='UM6'>(UTC -6:00) Central Standard Time</option>
334 <option value='UM5'>(UTC -5:00) Eastern Standard Time, Western Caribbean Standard Time</option>
335 <option value='UM45'>(UTC -4:30) Venezuelan Standard Time</option>
336 <option value='UM4'>(UTC -4:00) Atlantic Standard Time, Eastern Caribbean Standard Time</option>
337 <option value='UM35'>(UTC -3:30) Newfoundland Standard Time</option>
338 <option value='UM3'>(UTC -3:00) Argentina, Brazil, French Guiana, Uruguay</option>
339 <option value='UM2'>(UTC -2:00) South Georgia/South Sandwich Islands</option>
340 <option value='UM1'>(UTC -1:00) Azores, Cape Verde Islands</option>
341 <option value='UTC' selected='selected'>(UTC) Greenwich Mean Time, Western European Time</option>
342 <option value='UP1'>(UTC +1:00) Central European Time, West Africa Time</option>
343 <option value='UP2'>(UTC +2:00) Central Africa Time, Eastern European Time, Kaliningrad Time</option>
344 <option value='UP3'>(UTC +3:00) Moscow Time, East Africa Time</option>
345 <option value='UP35'>(UTC +3:30) Iran Standard Time</option>
346 <option value='UP4'>(UTC +4:00) Azerbaijan Standard Time, Samara Time</option>
347 <option value='UP45'>(UTC +4:30) Afghanistan</option>
348 <option value='UP5'>(UTC +5:00) Pakistan Standard Time, Yekaterinburg Time</option>
349 <option value='UP55'>(UTC +5:30) Indian Standard Time, Sri Lanka Time</option>
350 <option value='UP575'>(UTC +5:45) Nepal Time</option>
351 <option value='UP6'>(UTC +6:00) Bangladesh Standard Time, Bhutan Time, Omsk Time</option>
352 <option value='UP65'>(UTC +6:30) Cocos Islands, Myanmar</option>
353 <option value='UP7'>(UTC +7:00) Krasnoyarsk Time, Cambodia, Laos, Thailand, Vietnam</option>
354 <option value='UP8'>(UTC +8:00) Australian Western Standard Time, Beijing Time, Irkutsk Time</option>
355 <option value='UP875'>(UTC +8:45) Australian Central Western Standard Time</option>
356 <option value='UP9'>(UTC +9:00) Japan Standard Time, Korea Standard Time, Yakutsk Time</option>
357 <option value='UP95'>(UTC +9:30) Australian Central Standard Time</option>
358 <option value='UP10'>(UTC +10:00) Australian Eastern Standard Time, Vladivostok Time</option>
359 <option value='UP105'>(UTC +10:30) Lord Howe Island</option>
Peter Denk0ef898b2015-01-06 16:03:17 +0100360 <option value='UP11'>(UTC +11:00) Srednekolymsk Time, Solomon Islands, Vanuatu</option>
Derek Jonesa4db4322013-07-20 08:59:59 -0700361 <option value='UP115'>(UTC +11:30) Norfolk Island</option>
362 <option value='UP12'>(UTC +12:00) Fiji, Gilbert Islands, Kamchatka Time, New Zealand Standard Time</option>
363 <option value='UP1275'>(UTC +12:45) Chatham Islands Standard Time</option>
364 <option value='UP13'>(UTC +13:00) Phoenix Islands Time, Tonga</option>
365 <option value='UP14'>(UTC +14:00) Line Islands</option>
366 </select>
367 </form>
Derek Jones8ede1a22011-10-05 13:34:52 -0500368
369
Derek Jonesa4db4322013-07-20 08:59:59 -0700370 This menu is useful if you run a membership site in which your users are
371 allowed to set their local timezone value.
Derek Jones8ede1a22011-10-05 13:34:52 -0500372
Derek Jonesa4db4322013-07-20 08:59:59 -0700373 The first parameter lets you set the "selected" state of the menu. For
374 example, to set Pacific time as the default you will do this::
Derek Jones8ede1a22011-10-05 13:34:52 -0500375
Derek Jonesa4db4322013-07-20 08:59:59 -0700376 echo timezone_menu('UM8');
Derek Jones8ede1a22011-10-05 13:34:52 -0500377
Derek Jonesa4db4322013-07-20 08:59:59 -0700378 Please see the timezone reference below to see the values of this menu.
Derek Jones8ede1a22011-10-05 13:34:52 -0500379
Derek Jonesa4db4322013-07-20 08:59:59 -0700380 The second parameter lets you set a CSS class name for the menu.
Derek Jones8ede1a22011-10-05 13:34:52 -0500381
Derek Jonesa4db4322013-07-20 08:59:59 -0700382 The fourth parameter lets you set one or more attributes on the generated select tag.
Mat Whitney7540ded2012-06-22 12:02:10 -0700383
Derek Jonesa4db4322013-07-20 08:59:59 -0700384 .. note:: The text contained in the menu is found in the following
385 language file: `language/<your_lang>/date_lang.php`
Derek Jones8ede1a22011-10-05 13:34:52 -0500386
Derek Jones8ede1a22011-10-05 13:34:52 -0500387Timezone Reference
388==================
389
390The following table indicates each timezone and its location.
391
Kwaan Onlinee90b6842012-01-31 10:15:30 +0000392Note some of the location lists have been abridged for clarity and formatting.
393
Andrey Andreev3de130c2014-02-07 23:31:49 +0200394=========== =====================================================================
395Time Zone Location
396=========== =====================================================================
397UM12 (UTC - 12:00) Baker/Howland Island
398UM11 (UTC - 11:00) Samoa Time Zone, Niue
399UM10 (UTC - 10:00) Hawaii-Aleutian Standard Time, Cook Islands
400UM95 (UTC - 09:30) Marquesas Islands
401UM9 (UTC - 09:00) Alaska Standard Time, Gambier Islands
402UM8 (UTC - 08:00) Pacific Standard Time, Clipperton Island
403UM7 (UTC - 11:00) Mountain Standard Time
404UM6 (UTC - 06:00) Central Standard Time
405UM5 (UTC - 05:00) Eastern Standard Time, Western Caribbean
406UM45 (UTC - 04:30) Venezuelan Standard Time
407UM4 (UTC - 04:00) Atlantic Standard Time, Eastern Caribbean
408UM35 (UTC - 03:30) Newfoundland Standard Time
409UM3 (UTC - 03:00) Argentina, Brazil, French Guiana, Uruguay
410UM2 (UTC - 02:00) South Georgia/South Sandwich Islands
411UM1 (UTC -1:00) Azores, Cape Verde Islands
412UTC (UTC) Greenwich Mean Time, Western European Time
413UP1 (UTC +1:00) Central European Time, West Africa Time
414UP2 (UTC +2:00) Central Africa Time, Eastern European Time
415UP3 (UTC +3:00) Moscow Time, East Africa Time
416UP35 (UTC +3:30) Iran Standard Time
417UP4 (UTC +4:00) Azerbaijan Standard Time, Samara Time
418UP45 (UTC +4:30) Afghanistan
419UP5 (UTC +5:00) Pakistan Standard Time, Yekaterinburg Time
420UP55 (UTC +5:30) Indian Standard Time, Sri Lanka Time
421UP575 (UTC +5:45) Nepal Time
422UP6 (UTC +6:00) Bangladesh Standard Time, Bhutan Time, Omsk Time
423UP65 (UTC +6:30) Cocos Islands, Myanmar
424UP7 (UTC +7:00) Krasnoyarsk Time, Cambodia, Laos, Thailand, Vietnam
425UP8 (UTC +8:00) Australian Western Standard Time, Beijing Time
426UP875 (UTC +8:45) Australian Central Western Standard Time
427UP9 (UTC +9:00) Japan Standard Time, Korea Standard Time, Yakutsk
428UP95 (UTC +9:30) Australian Central Standard Time
429UP10 (UTC +10:00) Australian Eastern Standard Time, Vladivostok Time
430UP105 (UTC +10:30) Lord Howe Island
Peter Denk0ef898b2015-01-06 16:03:17 +0100431UP11 (UTC +11:00) Srednekolymsk Time, Solomon Islands, Vanuatu
Andrey Andreev3de130c2014-02-07 23:31:49 +0200432UP115 (UTC +11:30) Norfolk Island
433UP12 (UTC +12:00) Fiji, Gilbert Islands, Kamchatka, New Zealand
434UP1275 (UTC +12:45) Chatham Islands Standard Time
435UP13 (UTC +13:00) Phoenix Islands Time, Tonga
436UP14 (UTC +14:00) Line Islands
Andrey Andreev58f677f2013-07-16 11:01:37 +0300437=========== =====================================================================