Working with date and time - Jet\Data_DateTime

PHP itself has a great DataTime class. Jet makes full use of it, and the Jet\Data_DateTime class directly inherits from the PHP \DateTime class - so it can do exactly the same thing and is fully integrated into the Jet platform and is used, for example, in the ORM Jet DataModel. The excellent PHP class \DataTime is only minimally extended, but further extensions (while maintaining compatibility) cannot be ruled out in the future.

Overview of methods

Method Meaning of
public static now(
) : static
Creates an instance and immediately sets the current date and time
public setOnlyDate(
bool $only_date
) : void
Sets whether the object represents only the date.
public isOnlyDate(
) : bool
Indikuje zda objekt reprezentuje pouze datum.
public toString(
) : string
Converts the date and time to a string in ISO format Y-m-d\TH:i:s, or Y-m-d if the object represents only the date.

This is useful, for example, when storing time data in a database or other storage.
public __toString(
) : string
The object can be directly converted to a string. When doing so, the toString method is called.
public static catchDate(
Data_DateTime|string|null $value
) : ?static
It is used for catching time data from a input and returning it in the form of an instance of the Data_DateTime object if there is a valid date on a input, or NULL if there is no date on a input.
public static catchDateTime(
Data_DateTime|string|null $value
) : ?static
It is used for catching time data from a input and returning it in the form of an instance of the Data_DateTime object if there is a valid date and time on a input, or NULL if there is no date and time on a input.
Previous chapter
Working with an array - Jet\Data_Array
Next chapter
Working with images - Jet\Data_Image