Datetime
App\Shared\Services\DateTime
Method | Description | Type | Parameters | Return |
---|---|---|---|---|
__construct | public | string|null $time string|DateTimeZone|null $timezone string|null $locale |
Returns new Datetime object | |
getDateTime | public | |||
setTimezone | Sets the timezone |
public | DateTimeZone|string $timezone | CarbonImmutable false |
minuteInSeconds | public static |
int | ||
hourInSeconds | public static |
float int |
||
dayInSeconds | public static |
float int |
||
weekInSeconds | public static |
float int |
||
monthInSeconds | public static |
float int |
||
yearInSeconds | public static |
float int |
||
format | Formats date This function uses the set timezone from TriTan options Example Usage: $datetime = 'May 15, 2018 2:15 PM'; $this->format('Y-m-d H:i:s', $datetime); |
public | string $format Format of the date Default is Y-m-d H:i:s |
string |
gmtdate | Format a GMTUTC datetime |
public | string $date Date to be formatted Default is now string $format Format of the date Default is Y-m-d H:i:s |
string Formatted date string |
locale | public | object Returns current localized datetime | ||
db2Date | Converts given date string into a different format $format should be either a PHP date format string, eg 'U' for a Unix timestamp, or 'G' for a Unix timestamp assuming that $date is GMT If $translate is true, then the given date and format string will be passed to $this->locale() for translation |
public | string $format Format of the date to return string $date Date string to convert bool $translate Whether the return date should be translated Default true |
string int bool Formatted date string or Unix timestamp False if $date is empty |
current | The 'db' type will return the time in the format for database date field(s) The 'timestamp' type will return the current timestamp Other strings will be interpreted as PHP date formats (eg 'Y-m-d H:i:s') If $gmt is set to either '1' or 'true', then both types will use GMT time If $gmt is false, the output is adjusted with the GMT offset based on General Settings format string (eg 'Y-m-d') |
public | string $type Type of time to return Accepts 'db', 'timestamp', or PHP date bool $gmt Optional Whether to use GMT timezone Default false |
int string Integer if $type is 'timestamp', string otherwise |
timestampToDate | Converts timestamp to localized human-readable date |
public | string $format PHP date format string (eg 'Y-m-d') int $timestamp Timestamp to convert |
string Localized human readable date |