PHP Class JBZoo\Utils\Dates

Datei anzeigen Open project: jbzoo/utils Class Usage Examples

Public Methods

Method Description
factory ( mixed $time = null, null $timeZone = null ) : DateTime
human ( string | integer $date, string $format = 'd M Y H:i' ) : string
is ( string $date ) : boolean Check if string is date
isThisMonth ( string | integer $time ) : boolean Returns true if date passed is within this month.
isThisWeek ( string | integer $time ) : boolean Returns true if date passed is within this week.
isThisYear ( string | integer $time ) : boolean Returns true if date passed is within this year.
isToday ( string | integer $time ) : boolean Returns true if date passed is today.
isTomorrow ( string | integer $time ) : boolean Returns true if date passed is tomorrow.
isYesterday ( string | integer $time ) : boolean Returns true if date passed was yesterday.
sql ( null | integer $time = null ) : string Convert time for sql format
timezone ( mixed $timezone = null ) : DateTimeZone Return a DateTimeZone object based on the current timezone.
toStamp ( string | DateTim\DateTime $time = null, boolean $currentIsDefault = true ) : integer Convert to timestamp

Method Details

factory() public static method

public static factory ( mixed $time = null, null $timeZone = null ) : DateTime
$time mixed
$timeZone null
return DateTime

human() public static method

public static human ( string | integer $date, string $format = 'd M Y H:i' ) : string
$date string | integer
$format string
return string

is() public static method

Check if string is date
public static is ( string $date ) : boolean
$date string
return boolean

isThisMonth() public static method

Returns true if date passed is within this month.
public static isThisMonth ( string | integer $time ) : boolean
$time string | integer
return boolean

isThisWeek() public static method

Returns true if date passed is within this week.
public static isThisWeek ( string | integer $time ) : boolean
$time string | integer
return boolean

isThisYear() public static method

Returns true if date passed is within this year.
public static isThisYear ( string | integer $time ) : boolean
$time string | integer
return boolean

isToday() public static method

Returns true if date passed is today.
public static isToday ( string | integer $time ) : boolean
$time string | integer
return boolean

isTomorrow() public static method

Returns true if date passed is tomorrow.
public static isTomorrow ( string | integer $time ) : boolean
$time string | integer
return boolean

isYesterday() public static method

Returns true if date passed was yesterday.
public static isYesterday ( string | integer $time ) : boolean
$time string | integer
return boolean

sql() public static method

Convert time for sql format
public static sql ( null | integer $time = null ) : string
$time null | integer
return string

timezone() public static method

Return a DateTimeZone object based on the current timezone.
public static timezone ( mixed $timezone = null ) : DateTimeZone
$timezone mixed
return DateTimeZone

toStamp() public static method

Convert to timestamp
public static toStamp ( string | DateTim\DateTime $time = null, boolean $currentIsDefault = true ) : integer
$time string | DateTim\DateTime
$currentIsDefault boolean
return integer