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.
Previous chapter
Working with an array - Jet\Data_Array
Next chapter
Working with images - Jet\Data_Image