Skip to content

Abstract Class DateHelper

Methods

setTime

Returns a new DateTime object with the time set to the given time.

public static setTime(DateTimeInterface $date, DateTimeInterface $time): DateTime
$date DateTimeInterface
$time DateTimeInterface
return DateTime

endOfDay

Returns a new DateTime object with the time set to the end of the day.

public static endOfDay(DateTimeInterface $date): DateTime
$date DateTimeInterface
return DateTime

formatDate

public static formatDate(DateTimeInterface $startDate, "medium"|"long" $format = 'medium', ?string $timezone = null): string
$startDate DateTimeInterface
$format "medium"|"long"
$timezone ?string
return string

formatDateRange

public static formatDateRange(DateTimeInterface $startDate, ?DateTimeInterface $endDate, "medium"|"long" $format = 'medium', ?string $timezone = null): string
$startDate DateTimeInterface
$endDate ?DateTimeInterface
$format "medium"|"long"
$timezone ?string
return string

formatDatetimeRange

public static formatDatetimeRange(DateTimeInterface $startDate, DateTimeInterface $endDate, string $format = 'medium', ?string $timezone = null): string
$startDate DateTimeInterface
$endDate DateTimeInterface
$format string
$timezone ?string
return string

formatTimeRange

public static formatTimeRange(DateTimeInterface $startDate, DateTimeInterface $endDate, ?string $format = 'medium', ?string $timezone = null): string
$startDate DateTimeInterface
$endDate DateTimeInterface
$format ?string
$timezone ?string
return string