Class DATE_TIME

Description

Represents a date/time.

Maintains an internal date representation that can be returned as_php() or as_iso() or formatted with format(). The time can be set with set_from_php(), set_from_iso() or set_from_text() and cleared with clear(). Use is_valid() to check the date and equals(), less_than() and less_than_equal() to compare times and diff() to retrieve the difference as a TIME_INTERVAL.

Located in /lib/main/webcore/sys/date_time.php (line 580)

Inheritance Tree

RAISABLE
   |
   --DATE_TIME

Variable Summary

Method Summary

Variables

Protected Variable $_iso_time (line 968)

protected string $_iso_time = Date_time_unassigned

Protected Variable $_php_time (line 962)

protected integer $_php_time = Date_time_unassigned

Protected Variable $_toolkit (line 978)

Context-specific toolkit.

May be empty.

protected DATE_TIME_TOOLKIT $_toolkit

Methods

Constructor __construct (line 587)

public DATE_TIME __construct ([object $time = 0], [string $type = null])

Method as_iso (line 655)

Returns the ISO representation.

Use this format with DATABASEs. Example: 2000-12-21 16:01:07

public string as_iso ()

Method as_php (line 630)

Returns this object as a PHP timestamp.

public integer as_php ()

Method as_RFC_2822 (line 675)

Returns the RFC 2822 representation.

Use this format with the RSS_RENDERER. Example: Thu, 21 Dec 2000 16:01:07 +0200

public string as_RFC_2822 ()

Method as_RFC_3339 (line 686)

Returns the RFC 3339 representation.

Use this format with the RSS_RENDERER. Example: 2000-12-21T16:01:07+02:00

public string as_RFC_3339 ()

Method clear (line 749)

Clear the time.

This ensures that is_valid() returns false.

public void clear ()

Method diff (line 858)

The difference between the two times.

public TIME_INTERVAL diff (DATE_TIME $other)

Method equals (line 790)

Is this date equal to 'other'? Compares on the requested portions of the two dates.

public boolean equals (DATE_TIME $other, [int $parts = Date_time_both_parts])

Method format (line 763)

Format the date.

You can pass in a formatter, which is commonly obtained by calling 'formatter'. From that object, change the defaults, then call format with it. If you don't pass a formatter, the unmodified default is used.

public string format ([DATE_TIME_FORMATTER $formatter = 0])

Method formatter (line 868)

Returns the formatter for this date.

public DATE_TIME_FORMATTER formatter ()

Method format_plain (line 776)

Format the date without any highlighting.

public string format_plain ()

Method is_valid (line 621)

public boolean is_valid ()

The last valid day of any month.

This is useful for building calendars. Handles leap years.

public integer last_legal_day ()

Method less_than (line 814)

Is this date less than 'other'? Compares on the requested portions of the two dates.

public boolean less_than (DATE_TIME $other, [int $parts = Date_time_both_parts])

Method less_than_equal (line 802)

Is this date less than or equal to 'other'? Compares on the requested portions of the two dates.

public boolean less_than_equal (DATE_TIME $other, [int $parts = Date_time_both_parts])

Method set_from_iso (line 695)

Sets the date and time from an ISO-formatted string.

public void set_from_iso (string $t)

  • string $t

Method set_from_php (line 705)

Sets the date and time from a PHP timestamp.

public void set_from_php (string $t)

  • string $t

Method set_from_text (line 734)

Set the time from a user input.

Supported formats are determined by the DATE_TIME_CONVERTERs registered with the toolkit().

public void set_from_text (string $t, [integer $parts = Date_time_both_parts])

Method set_now (line 740)

public void set_now ()

Method set_time_from_iso (line 715)

Sets the time from an ISO-formatted string.

public void set_time_from_iso (string $t)

  • string $t

Method toolkit (line 883)

Returns the toolki for this date/time.

This basic date/time class uses the global_date_time_toolkit(), which is fine for most applications. Applications which need specialized toolkits can define a descendent and redefine this function.

public DATE_TIME_TOOLKIT toolkit ()

Method use_toolkit (line 901)

Use the given toolkit for conversions and formatting.

public void use_toolkit (DATE_TIME_TOOLKIT $toolkit)

Protected Method _compare_to (line 913)

Compare against 'other' using 'operator'.

protected boolean _compare_to (DATE_TIME $other, int $operator, int $parts)