Date Class

DateTime replacement that supports internationalization and does correction to GMT when your webserver isn't configured correctly.

package Fuel
subpackage Core
category Core
link Always returns Date objects, will accept both Date objects and UNIX timestamps - create_time() uses strptime and has currently a very bad hack to use strtotime for windows servers - Uses strftime formatting for dates www.php.net/manual/en/function.strftime.php

 Methods

__construct()

__construct($timestamp, $timezone) 

Parameters

$timestamp

$timezone

Allows you to just put the object in a string and get it inserted in the default pattern

__toString() : string

Returns

string

_init()

_init() 

Uses the date config file to translate string input to timestamp

create_from_string(string $input, string $pattern_key) : \Fuel\Core\Date

Parameters

$input

string

date/time input

$pattern_key

string

key name of pattern in config file

Returns

Returns the number of days in the requested month

days_in_month(int $month, int $year) : int

Parameters

$month

int

month as a number (1-12)

$year

int

the year, leave empty for current

Returns

intthe number of days in the month

Returns the current time with offset

display_timezone(string $timezone) : string

Parameters

$timezone

string

valid PHP timezone from www.php.net/timezones

Returns

string

Create Date object from timestamp, timezone is optional

forge(int $timestamp, string $timezone) : \Fuel\Core\Date

Parameters

$timestamp

int

UNIX timestamp from current server

$timezone

string

valid PHP timezone from www.php.net/timezones

Returns

Returns the date formatted according to the current locale

format(string $pattern_key, mixed $timezone) : string

Parameters

$pattern_key

string

either a named pattern from date config file or a pattern, defaults to 'local'

$timezone

mixed

vald timezone, or if true, output the time in local time instead of system time

Returns

string

Returns the internal timestamp

get_timestamp() : int

Returns

int

Returns the internal timezone

get_timezone() : string

Returns

string

Returns the internal timezone or the display timezone abbreviation

get_timezone_abbr(boolean $display_timezone) : string

Parameters

$display_timezone

boolean

Returns

string

Fetches an array of Date objects per interval within a range

range_to_array(int | \Fuel\Core\Date $start, int | \Fuel\Core\Date $end, int | string $interval) : array

Parameters

$start

int\Fuel\Core\Date

start of the range

$end

int\Fuel\Core\Date

end of the range

$interval

intstring

Length of the interval in seconds or valid strtotime time difference

Returns

arrayarray of Date objects

Change the timezone

set_timezone(string $timezone) : \Fuel\Core\Date

Parameters

$timezone

string

timezone from www.php.net/timezones

Returns

Returns the current time with offset

time(string $timezone) : \Fuel\Core\Date

Parameters

$timezone

string

valid PHP timezone from www.php.net/timezones

Returns

Returns the time ago

time_ago(int $timestamp, int $from_timestamp, string $unit) : string

Parameters

$timestamp

int

UNIX timestamp from current server

$from_timestamp

int

UNIX timestamp to compare against. Default to the current time

$unit

string

Unit to return the result in

Returns

stringTime ago

 Properties

 

<p>the timezone to be used to output formatted data</p>

$display_timezone : string

 

<p>server's time() offset from gmt in seconds</p>

$server_gmt_offset : int

 

<p>instance timestamp</p>

$timestamp : int

 

<p>output timezone</p>

$timezone : string

 Constants

 

DAY

DAY 

 

HOUR

HOUR 

 

MINUTE

MINUTE 

 

Time constants (and only those that are constant, thus not MONTH/YEAR)

WEEK