DateTimeZoneCustom
in package
Class DateTimeZoneCustom
Provides utility functions for handling date and time with specific timezone settings.
Table of Contents
Methods
- dateTimeToStringConverter() : string
- Converts a DateTime object to a string in 'Y-m-d H:i:s' format.
- dateTimeToStringConverterWithoutSeconds() : string
- Converts a DateTime object to a string in 'Y-m-d H:i' format (without seconds).
- getCurrentDateTimeInString() : string
- Gets the current date and time as a string in 'America/Sao_Paulo' timezone.
- stringToDateTimeConverter() : DateTime
- Converts a string to a DateTime object in 'America/Sao_Paulo' timezone.
Methods
dateTimeToStringConverter()
Converts a DateTime object to a string in 'Y-m-d H:i:s' format.
public
static dateTimeToStringConverter(DateTime $date) : string
Parameters
- $date : DateTime
-
The DateTime object to convert.
Return values
string —The formatted date and time string.
dateTimeToStringConverterWithoutSeconds()
Converts a DateTime object to a string in 'Y-m-d H:i' format (without seconds).
public
static dateTimeToStringConverterWithoutSeconds(DateTime $date) : string
Parameters
- $date : DateTime
-
The DateTime object to convert.
Return values
string —The formatted date and time string without seconds.
getCurrentDateTimeInString()
Gets the current date and time as a string in 'America/Sao_Paulo' timezone.
public
static getCurrentDateTimeInString() : string
Return values
string —The current date and time in 'Y-m-d H:i:s' format.
stringToDateTimeConverter()
Converts a string to a DateTime object in 'America/Sao_Paulo' timezone.
public
static stringToDateTimeConverter(string $date) : DateTime
Parameters
- $date : string
-
The date string to convert.
Return values
DateTime —The DateTime object.