The Date Helper file contains functions that assist in working with dates.
This helper is loaded using the following code:
helper('date');
The following functions are available:
now([$timezone = null]) | Parameters: |
|
|---|---|
| Returns: |
UNIX timestamp |
| Return type: |
int |
Returns the current time as a UNIX timestamp, referenced either to your server’s local time or any PHP supported timezone, based on the “time reference” setting in your config file. If you do not intend to set your master time reference to any other PHP supported timezone (which you’ll typically do if you run a site that lets each user set their own timezone settings) there is no benefit to using this function over PHP’s time() function.
echo now('Australia/Victoria');
If a timezone is not provided, it will return time() based on the time_reference setting.
timezone_select([$class = '', $default = '', $what = DateTimeZone::ALL, $country = null]) | Parameters: |
|
|---|---|
| Returns: |
Preformatted HTML select field |
| Return type: |
string |
Generates a select form field of available timezones (optionally filtered by $what and $country). You can supply an option class to apply to the field to make formatting easier, as well as a default selected value.
echo timezone_select('custom-select', 'America/New_York');
Many functions previously found in the CodeIgniter 3 date_helper have been moved to the I18n module in CodeIgniter 4.
© 2014–2020 British Columbia Institute of Technology
Licensed under the MIT License.
https://codeigniter.com/user_guide/helpers/date_helper.html