DateTimeModifyTrait
+ Inheritance diagram for DateTimeModifyTrait:

Description

Date-time component modifiers.

Public Methods

DateTime firstDayOfMonth ()
 YYYY-MM-01 More...
 
DateTime firstDayOfYear ()
 YYYY-01-01 More...
 
DateTime lastDayOfMonth ()
 YYYY-MM-DD More...
 
DateTime lastDayOfYear ()
 YYYY-12-31 More...
 
DateTime modify ($s, int $m=0, int $h=0, int $D=0, int $M=0, int $Y=0)
 Applies date-time modifiers. More...
 
DateTime setDate (int $day=null, int $month=null, int $year=null)
 Manually set the date components, preserving the time. More...
 
DateTime setDay (int $day)
 
DateTime setHours (int $hours)
 
DateTime setMinutes (int $minutes)
 
DateTime setMonth (int $month)
 
DateTime setSeconds (int $seconds)
 
DateTime setTime (int $seconds=null, int $minutes=null, int $hours=null)
 Manually set the time components, preserving the date. More...
 
DateTime setYear (int $year)
 
DateTime toUTC (string $mysqlLocalTz=null)
 Changes the timezone from local to UTC. More...
 
- Public Methods inherited from DateTimeFormatTrait
DateTime date ()
 YYYY-MM-DD More...
 
Str dateFormat ($format)
 Date formatting expression using a driver-appropriate function. More...
 
DateTime datetime ()
 YYYY-MM-DD hh:mm:ss More...
 
Num day ()
 01 to 31 More...
 
Num dayOfWeek ()
 0 to 6 (Sunday is 0) More...
 
Num dayOfYear ()
 001 to 366 (365 + 1 during leap year) More...
 
Num hours ()
 00 to 23 More...
 
Str iso8601 ()
 ISO-8601 compatible datetime string, offset Z (UTC/Zulu) More...
 
Num julian ()
 Julian day number (fractional). More...
 
Num minutes ()
 00 to 59 More...
 
Num month ()
 01 to 12 More...
 
Num seconds ()
 00 to 59 More...
 
Str time ()
 00:00:00 to 23:59:59 More...
 
Num timestamp ()
 Unix timestamp. More...
 
Num weekOfYear ()
 00 to 53 More...
 
Num year ()
 YYYY More...
 

Methods

◆ firstDayOfMonth()

DateTime firstDayOfMonth ( )

YYYY-MM-01

Returns
DateTime

◆ firstDayOfYear()

DateTime firstDayOfYear ( )

YYYY-01-01

Returns
DateTime

◆ lastDayOfMonth()

DateTime lastDayOfMonth ( )

YYYY-MM-DD

Returns
DateTime

◆ lastDayOfYear()

DateTime lastDayOfYear ( )

YYYY-12-31

Returns
DateTime

◆ modify()

DateTime modify (   $s,
int  $m = 0,
int  $h = 0,
int  $D = 0,
int  $M = 0,
int  $Y = 0 
)

Applies date-time modifiers.

$s can be a DateInterval or DateInterval description (e.g. "+1 day"). If so, the rest of the arguments are ignored.

Note: Modifiers are processed from greatest-to-least interval scope, meaning years are applied first and seconds are applied last.

Parameters
int | string | DateInterval$sSeconds, or DateInterval related
int$mMinutes
int$hHours
int$DDays
int$MMonths
int$YYears
Returns
DateTime

◆ setDate()

DateTime setDate ( int  $day = null,
int  $month = null,
int  $year = null 
)

Manually set the date components, preserving the time.

NULL can be given to preserve a component's value.

Parameters
null | int$day
null | int$month
null | int$year
Returns
DateTime

◆ setDay()

DateTime setDay ( int  $day)
Parameters
int$day
Returns
DateTime

◆ setHours()

DateTime setHours ( int  $hours)
Parameters
int$hours
Returns
DateTime

◆ setMinutes()

DateTime setMinutes ( int  $minutes)
Parameters
int$minutes
Returns
DateTime

◆ setMonth()

DateTime setMonth ( int  $month)
Parameters
int$month
Returns
DateTime

◆ setSeconds()

DateTime setSeconds ( int  $seconds)
Parameters
int$seconds
Returns
DateTime

◆ setTime()

DateTime setTime ( int  $seconds = null,
int  $minutes = null,
int  $hours = null 
)

Manually set the time components, preserving the date.

NULL can be given to preserve a component's value.

Parameters
null | int$seconds
null | int$minutes
null | int$hours
Returns
DateTime

◆ setYear()

DateTime setYear ( int  $year)
Parameters
int$year
Returns
DateTime

◆ toUTC()

DateTime toUTC ( string  $mysqlLocalTz = null)

Changes the timezone from local to UTC.

SQLite uses the system's timezone as the "local" timezone, whereas MySQL allows you to specify it.

Warning: Datetimes are already stored and retrieved as UTC. Only use this if you know the expression is in the local timezone.

Warning: Chaining this multiple times will further change the timezone offset.

Parameters
null | string$mysqlLocalTzThe "local" timezone name or offset given to MySQL. Defaults to PHP's current timezone.
Returns
DateTime