PHP Class Ouzo\Utilities\Date

Datei anzeigen Open project: letsdrink/ouzo Class Usage Examples

Public Methods

Method Description
addInterval ( string $interval, string $format = self::DEFAULT_TIME_FORMAT ) : string Adds interval to current time and returns a formatted date.
beginningOfDay ( string $date ) : string Returns the beginning of a day for the given date.
endOfDay ( string $date ) : string Returns end of a day for the given date.
formatDate ( string $date, string $format = 'Y-m-d' ) : null | string Returns formatted date.
formatDateTime ( string $date, string $format = self::DEFAULT_TIME_FORMAT ) : null | string Returns formatted date time.
formatTime ( string $time, string $format = 'H:i' ) : null | string Returns formatted time.
formatTimestamp ( integer $timestamp, string $format = self::DEFAULT_TIME_FORMAT, string $timezone = self::DEFAULT_TIMEZONE ) : string Returns formatted Unix timestamp.
modify ( string $dateAsString, string $interval, string $format = self::DEFAULT_TIME_FORMAT ) : string Modifies the given date string and returns a formatted date.
modifyNow ( string $interval, string $format = self::DEFAULT_TIME_FORMAT ) : string Modifies the current time and returns a formatted date.

Method Details

addInterval() public static method

Adds interval to current time and returns a formatted date.
public static addInterval ( string $interval, string $format = self::DEFAULT_TIME_FORMAT ) : string
$interval string
$format string
return string

beginningOfDay() public static method

Example: $date = '2013-09-09 13:03:43'; $begin = Date::beginningOfDay($date); Result: 2013-09-09 00:00:00
public static beginningOfDay ( string $date ) : string
$date string
return string

endOfDay() public static method

Example: $date = '2013-09-09 13:03:43'; $end = Date::endOfDay($date); Result: 2013-09-09 23:59:59.9999
public static endOfDay ( string $date ) : string
$date string
return string

formatDate() public static method

Returns formatted date.
public static formatDate ( string $date, string $format = 'Y-m-d' ) : null | string
$date string
$format string
return null | string

formatDateTime() public static method

Returns formatted date time.
public static formatDateTime ( string $date, string $format = self::DEFAULT_TIME_FORMAT ) : null | string
$date string
$format string
return null | string

formatTime() public static method

Returns formatted time.
public static formatTime ( string $time, string $format = 'H:i' ) : null | string
$time string
$format string
return null | string

formatTimestamp() public static method

Returns formatted Unix timestamp.
public static formatTimestamp ( integer $timestamp, string $format = self::DEFAULT_TIME_FORMAT, string $timezone = self::DEFAULT_TIMEZONE ) : string
$timestamp integer
$format string
$timezone string
return string

modify() public static method

Modifies the given date string and returns a formatted date.
public static modify ( string $dateAsString, string $interval, string $format = self::DEFAULT_TIME_FORMAT ) : string
$dateAsString string
$interval string
$format string
return string

modifyNow() public static method

Modifies the current time and returns a formatted date.
public static modifyNow ( string $interval, string $format = self::DEFAULT_TIME_FORMAT ) : string
$interval string
$format string
return string