as_get_datetime_object( mixed $date_string = null, string $timezone = 'UTC' )

Helper function to create an instance of DateTime based on a given string and timezone. By default, will return the current date/time in the UTC timezone.


Description Description

Needed because new DateTime() called without an explicit timezone will create a date/time in PHP’s timezone, but we need to have assurance that a date/time uses the right timezone (which we almost always want to be UTC), which means we need to always include the timezone when instantiating datetimes rather than leaving it up to the PHP default.


Parameters Parameters

$date_string

(Optional) A date/time string. Valid formats are explained in <a href="http://php.net/manual/en/datetime.formats.php">http://php.net/manual/en/datetime.formats.php</a>.

Default value: null

$timezone

(Optional) A timezone identifier, like UTC or Europe/Lisbon. The list of valid identifiers is available <a href="http://php.net/manual/en/timezones.php">http://php.net/manual/en/timezones.php</a>.

Default value: 'UTC'


Top ↑

Return Return

(ActionScheduler_DateTime)


Top ↑

Source Source

File: packages/action-scheduler/functions.php


			


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.