$value
$value : null|\DateTime
Standard object abstract class.
Extend this class when you want to create your own standard object.
$formatters : \app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject
A list of valid date formats grouped by their type.
$dateTimeFormat : null|\app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject
largerThan(integer|string|\DateTime|\app\framework\Component\StdLib\StdObject\DateTimeObject\DateTimeObject $time) : boolean
Check if current datetime is larger than $time.
integer|string|\DateTime|\app\framework\Component\StdLib\StdObject\DateTimeObject\DateTimeObject | $time | Date to compare to. |
Boolean true if current date object is larger than the provided $time.
smallerThan(integer|string|\DateTime|\app\framework\Component\StdLib\StdObject\DateTimeObject\DateTimeObject $time) : boolean
Check if current datetime smaller than $time.
integer|string|\DateTime|\app\framework\Component\StdLib\StdObject\DateTimeObject\DateTimeObject | $time | Date to compare to. |
Boolean true if current date object is smaller than the provided $time.
add(string $amount) : $this
Adds an amount of days, months, years, hours, minutes and seconds to a DateTimeObject.
string | $amount | You can specify the amount in ISO8601 format (example: 'P14D' = 14 days; 'P1DT12H' = 1 day 12 hours), or as a date string (example: '1 day', '2 months', '3 year', '2 days + 10 minutes'). |
sub(string $amount) : $this
Subtracts an amount of days, months, years, hours, minutes and seconds from current DateTimeObject.
string | $amount | You can specify the amount in ISO8601 format (example: 'P14D' = 14 days; 'P1DT12H' = 1 day 12 hours), or as a date string (example: '1 day', '2 months', '3 year', '2 days + 10 minutes'). |
offsetToTimezone(string|\DateTimeZone $timezone) : $this
Offsets the date object from current timezone to defined $timezone.
This is an alias of DateTimeObject::setTimezone.
string|\DateTimeZone | $timezone | Timezone to which you wish to offset. You can either pass \DateTimeZone object or a valid timezone string. For timezone string formats visit: http://php.net/manual/en/timezones.php |
isSerialized(string $value, mixed $result = null) : boolean
Checks if a string is serialized using quick string manipulation to throw out obviously incorrect strings. Unserialize is then run on the string to perform the final verification.
Valid serialized forms are the following:
b:1;
i:1;
d:0.2;
s:4:"test";
a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}
O:8:"stdClass":0:{}
N;
string | $value | Value to test for serialized form |
mixed | $result | Result of unserialize() of the $value |
True if $value is serialized data, otherwise false
__construct(string|integer $time = "now", null|string $timezone = null)
Constructor.
Set standard object value.
string|integer | $time | A date/time string. List of available formats is explained here http://www.php.net/manual/en/datetime.formats.php |
null|string | $timezone | Timezone in which you want to set the date. Here is a list of valid timezones: http://php.net/manual/en/timezones.php |
setFormat(string $format) : $this
Set the date format.
string | $format | Date format. These are the valid options: http://php.net/manual/en/function.date.php |
setTimezone(string|\DateTimeZone $timezone) : $this
Set a new timezone for current date object.
NOTE: The current timestamp will be recalculated with the offset of current timezone and the new defined one.
string|\DateTimeZone | $timezone | Timezone to which you wish to offset. You can either pass \DateTimeZone object or a valid timezone string. For timezone string formats visit: http://php.net/manual/en/timezones.php |
getTimeAgo(null $from = null) : string
Calculates the time passed between current date and $form (default: now).
The output is formatted in plain words, like "4 hours ago".
null | $from | Timestamp from where to calculate the offset. Default is now. |
String describing the passed time. Example "4 hours ago".
getDateElement(string $dateElement, null|string $format = null) : string
Returns defined $dateElement in defined $format.
string | $dateElement | Possible values are: date, year, month, day, time, hour, minutes, seconds, meridiem. |
null|string | $format | For list of possible formats check: http://php.net/manual/en/function.date.php |
createTimezone(string|null $timezone = null) : \DateTimeZone
Create a DateTimeZone object for the given $timeZone.
If $timezone is undefined, default timezone is returned. Default timezone is the servers timezone.
string|null | $timezone | A valid time zone. For list of available timezones visit: http://www.php.net/manual/en/timezones.php |
validateFormatFor(string $dateElement, string $format) : mixed
Checks if $format is a valid format for $dateElement.
string | $dateElement | Possible values are: date, year, month, day, time, hour, minutes, seconds, meridiem. |
string | $format | For list of possible formats check: http://php.net/manual/en/function.date.php |