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)
RAISABLE | --DATE_TIME
public DATE_TIME __construct ([object $time = 0], [string $type = null])
Use this format with DATABASEs. Example: 2000-12-21 16:01:07
public string as_iso ()
Use this format with the RSS_RENDERER. Example: Thu, 21 Dec 2000 16:01:07 +0200
public string as_RFC_2822 ()
Use this format with the RSS_RENDERER. Example: 2000-12-21T16:01:07+02:00
public string as_RFC_3339 ()
public TIME_INTERVAL diff (DATE_TIME $other)
public boolean equals (DATE_TIME $other, [int $parts = Date_time_both_parts])
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])
public boolean is_valid ()
This is useful for building calendars. Handles leap years.
public integer last_legal_day ()
public boolean less_than (DATE_TIME $other, [int $parts = Date_time_both_parts])
public boolean less_than_equal (DATE_TIME $other, [int $parts = Date_time_both_parts])
public void set_from_iso (string $t)
public void set_from_php (string $t)
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])
public void set_now ()
public void set_time_from_iso (string $t)
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 ()
public void use_toolkit (DATE_TIME_TOOLKIT $toolkit)
protected boolean _compare_to (DATE_TIME $other, int $operator, int $parts)