Public Member Functions | |
| set_date ($year, $month, $day) | |
| set_isodate ($year, $week, $day=null) | |
| set_time ($hour, $minute, $second=null) | |
| set_timezone ($timezone) | |
| get_timezone () | |
| format ($format=null) | |
| text_format ($format) | |
| modify ($args) | |
| get ($format=null) | |
| out ($format=null) | |
| __toString () | |
| __get ($property) | |
| getdate () | |
| friendly ($precision=7, $include_suffix=true) | |
| fuzzy () | |
Static Public Member Functions | |
| static | __static () |
| static | set_default_datetime_format ($format) |
| static | get_default_datetime_format () |
| static | set_default_timezone ($timezone) |
| static | get_default_timezone () |
| static | date_create ($time=null, $timezone=null) |
| static | get_default_date_format () |
| static | get_default_time_format () |
| static | difference ($start_date, $end_date) |
Public Attributes | |
| const | YEAR = 31556926 |
| const | MONTH = 2629744 |
| const | WEEK = 604800 |
| const | DAY = 86400 |
| const | HOUR = 3600 |
| const | MINUTE = 60 |
Definition at line 18 of file habaridatetime.php.
| HabariDateTime::__get | ( | $ | property | ) |
Magic method to get magic ponies... properties, I mean.
Definition at line 295 of file habaridatetime.php.
| static HabariDateTime::__static | ( | ) | [static] |
Set default timezone to system default on init.
Definition at line 38 of file habaridatetime.php.
| HabariDateTime::__toString | ( | ) |
Magic method called when this object is cast to string. Returns the unix timestamp of this object.
Definition at line 287 of file habaridatetime.php.
| static HabariDateTime::date_create | ( | $ | time = null, |
|
| $ | timezone = null | |||
| ) | [static] |
Helper function to create a HabariDateTime object for the given time and timezone. If no time is given, defaults to 'now'. If no timezone given defaults to timezone set in set_default_timezone()
| string | $time String in a format accepted by strtotime(), defaults to "now". | |
| string | $timezone A timezone name, not an abbreviation. |
Definition at line 115 of file habaridatetime.php.
Referenced by LogEntry::__construct(), CronJob::__construct(), Post::__set(), LogEntry::__set(), CronJob::__set(), Comment::__set(), UserHandler::act_login(), CronTab::act_poll_cron(), CoreBlocks::action_block_content_monthly_archives(), FeedbackHandler::add_comment(), Update::check_plugins(), AtomHandler::create_atom_wrapper(), Post::default_fields(), LogEntry::default_fields(), CronJob::default_fields(), Comment::default_fields(), difference(), Format::format_date(), fuzzy(), Session::gc(), EventLog::get(), Posts::get(), Comments::get(), AdminCommentsHandler::get_comment(), AtomHandler::get_comments(), AdminDashboardHandler::get_dashboard(), AdminUsersHandler::get_user(), Post::insert(), Format::nice_date(), Format::nice_time(), AdminOptionsHandler::post_options(), Post::publish(), Posts::publish_scheduled_posts(), Session::read(), CronTab::run_cron(), Post::update(), Posts::update_scheduled_posts_cronjob(), Session::write(), and Pingback::xmlrpc_pingback__ping().
| static HabariDateTime::difference | ( | $ | start_date, | |
| $ | end_date | |||
| ) | [static] |
Returns an array representing the difference between two times by interval.
print_r( HabariDateTime::difference( 'now', 'January 1, 2010' ) ); // output (past): Array ( [invert] => [y] => 0 [m] => 9 [w] => 3 [d] => 5 [h] => 22 [i] => 33 [s] => 5 ) print_r( HabariDateTime::difference( 'now', 'January 1, 2011' ) ); // output (future): Array ( [invert] => 1 [y] => 0 [m] => 2 [w] => 0 [d] => 3 [h] => 5 [i] => 33 [s] => 11 )
If 'invert' is true, the time is in the future (ie: x from now). If it is false, the time is in the past (ie: x ago).
For more information, see PHP's DateInterval class, which this and friendly() attempt to emulate for < PHP 5.3
| mixed | $start_date The start date, as a HDT object or any format accepted by HabariDateTime::date_create(). | |
| mixed | $end_date The end date, as a HDT object or any format accepted by HabariDateTime::date_create(). |
Definition at line 495 of file habaridatetime.php.
Referenced by friendly().
| HabariDateTime::format | ( | $ | format = null |
) |
Returns date formatted according to given format.
Definition at line 216 of file habaridatetime.php.
Referenced by __get(), __toString(), get(), getdate(), and out().
| HabariDateTime::friendly | ( | $ | precision = 7, |
|
| $ | include_suffix = true | |||
| ) |
Returns a friendlier string version of the time, ie: 3 days, 1 hour, and 5 minutes ago
| int | $precision Only display x intervals. Note that this does not round, it only limits the display length. | |
| boolean | $include_suffix Include the 'ago' or 'from now' suffix? |
Definition at line 378 of file habaridatetime.php.
Referenced by __get().
| HabariDateTime::fuzzy | ( | ) |
Similar to friendly(), but much more... fuzzy.
Returns a very short version of the difference in time between now and the current HDT object.
Definition at line 439 of file habaridatetime.php.
Referenced by __get().
| HabariDateTime::get | ( | $ | format = null |
) |
| static HabariDateTime::get_default_date_format | ( | ) | [static] |
Return the default date format, as set in the Options table
Definition at line 342 of file habaridatetime.php.
| static HabariDateTime::get_default_datetime_format | ( | ) | [static] |
Get the default date/time format set.
Definition at line 74 of file habaridatetime.php.
| static HabariDateTime::get_default_time_format | ( | ) | [static] |
Return the default time format, as set in the Options table
Definition at line 352 of file habaridatetime.php.
| static HabariDateTime::get_default_timezone | ( | ) | [static] |
Get the timezone for Habari and PHP. Defaults to system timezone if not set.
| string | The deafult timezone. |
Definition at line 99 of file habaridatetime.php.
| HabariDateTime::get_timezone | ( | ) |
Get the timezone identifier that is set for this datetime object.
Definition at line 204 of file habaridatetime.php.
| HabariDateTime::getdate | ( | ) |
Returns an associative array containing the date information for this HabariDateTime object, as per getdate()
Definition at line 363 of file habaridatetime.php.
Referenced by __get().
| HabariDateTime::modify | ( | $ | args | ) |
Alters the timestamp
| string | $format A format accepted by strtotime(). |
Definition at line 256 of file habaridatetime.php.
| HabariDateTime::out | ( | $ | format = null |
) |
Echos date formatted according to given format.
Definition at line 276 of file habaridatetime.php.
| HabariDateTime::set_date | ( | $ | year, | |
| $ | month, | |||
| $ | day | |||
| ) |
Set the date of this object
| int | $year Year of the date | |
| int | $month Month of the date | |
| int | $day Day of the date |
Definition at line 148 of file habaridatetime.php.
| static HabariDateTime::set_default_datetime_format | ( | $ | format | ) | [static] |
Set default date/time format. The format is the same as the internal php date() function.
| string | $format The date format. |
Definition at line 62 of file habaridatetime.php.
Referenced by __static().
| static HabariDateTime::set_default_timezone | ( | $ | timezone | ) | [static] |
Sets the timezone for Habari and PHP.
| string | $timezone A timezone name, not an abbreviation, for example 'America/New York' |
Definition at line 85 of file habaridatetime.php.
Referenced by __static().
| HabariDateTime::set_isodate | ( | $ | year, | |
| $ | week, | |||
| $ | day = null | |||
| ) |
Sets the ISO date
| int | $year Year of the date | |
| int | $month Month of the date | |
| int | $day Day of the date |
Definition at line 162 of file habaridatetime.php.
| HabariDateTime::set_time | ( | $ | hour, | |
| $ | minute, | |||
| $ | second = null | |||
| ) |
Set the time of this object
| int | $hour Hour of the time | |
| int | $minute Minute of the time | |
| int | $second Second of the time |
Definition at line 176 of file habaridatetime.php.
| HabariDateTime::set_timezone | ( | $ | timezone | ) |
Set the timezone for this datetime object. Can be either string timezone identifier, or DateTimeZone object.
| mixed | The timezone to use. |
Definition at line 190 of file habaridatetime.php.
| HabariDateTime::text_format | ( | $ | format | ) |
Returns date components inserted into a string
Example: echo HabariDateTime::date_create('2010-01-01')->text_format('The year was {Y}.'); // Expected output: The year was 2010.
| string | $format A string with single-character date format codes date() surrounded by braces |
Definition at line 234 of file habaridatetime.php.
1.7.1