Class ImmutableDateTime
Representation of a date and time.
<?php // Let's say that _now_ is 2013-02-03 21:03:45 in Paris use ICanBoogie\ImmutableDateTime; date_default_timezone_set('EST'); // set local time zone to Eastern Standard Time $time = new ImmutableDateTime('now', 'Europe/Paris'); echo $time; // 2013-02-03T21:03:45+01:00 echo $time->utc; // 2013-02-03T20:03:45Z echo $time->local; // 2013-02-03T15:03:45-05:00 echo $time->utc->local; // 2013-02-03T15:03:45-05:00 echo $time->utc->is_utc; // true echo $time->utc->is_local; // false echo $time->local->is_utc; // false echo $time->local->is_local; // true echo $time->is_dst; // false echo $time->as_rss; // Sun, 03 Feb 2013 21:03:45 +01:00 echo $time->as_db; // 2013-02-03 21:03:45 echo $time->as_time; // 21:03:45 echo $time->utc->as_time; // 20:03:45 echo $time->local->as_time; // 15:03:45 echo $time->utc->local->as_time; // 15:03:45 echo $time->quarter; // 1 echo $time->week; // 5 echo $time->day; // 3 echo $time->minute; // 3 echo $time->is_monday; // false echo $time->is_saturday; // true echo $time->is_today; // true echo $time->tomorrow; // 2013-02-04T00:00:00+01:00 echo $time->tomorrow->is_future // true echo $time->yesterday; // 2013-02-02T00:00:00+01:00 echo $time->yesterday->is_past // true echo $time->monday; // 2013-01-28T00:00:00+01:00 echo $time->sunday; // 2013-02-03T00:00:00+01:00 echo $time->timestamp; // 1359921825 echo $time; // 2013-02-03T21:03:45+01:00 $time->timestamp += 3600 * 4; echo $time; // 2013-02-04T01:03:45+01:00 echo $time->timezone; // Europe/Paris // or echo $time->tz; // Europe/Paris echo $time->tz->offset; // 3600 echo $time->tz->location; // FR,48.86667,2.33333 echo $time->tz->location->latitude; // 48.86667
Empty dates are also supported:
<?php use ICanBoogie\ImmutableDateTime as ImmutableDateTime; $time = new DateTime('0000-00-00', 'utc'); // or $time = DateTime::none(); echo $time->is_empty; // true echo $time->as_date; // 0000-00-00 echo $time->as_db; // 0000-00-00 00:00:00 echo $time; // ""
- DateTimeImmutable implements DateTimeInterface
- ┗ ICanBoogie\ImmutableDateTime implements JsonSerializable, ICanBoogie\DateTime uses ICanBoogie\DateTime\Shared, ICanBoogie\DateTime\Readers
Methods summary
Methods inherited from DateTimeImmutable
__construct()
,
__set_state()
,
__wakeup()
,
add()
,
createFromFormat()
,
createFromMutable()
,
diff()
,
format()
,
getLastErrors()
,
getOffset()
,
getTimestamp()
,
getTimezone()
,
modify()
,
setDate()
,
setISODate()
,
setTime()
,
setTimestamp()
,
setTimezone()
,
sub()
Methods inherited from JsonSerializable
jsonSerialize()
Methods inherited from ICanBoogie\DateTime
change()
,
from()
,
localize()
,
none()
,
right_now()
Methods used from ICanBoogie\DateTime\Shared
__call()
,
__construct()
,
__toString()
,
change()
,
format()
,
from()
,
getTimestamp()
,
getTimezone()
,
jsonSerialize()
,
localize()
,
none()
,
right_now()
,
setDate()
,
setTime()
,
setTimezone()
Methods used from ICanBoogie\DateTime\Readers
__get()
,
get_friday()
,
get_immutable()
,
get_is_dst()
,
get_monday()
,
get_mutable()
,
get_saturday()
,
get_sunday()
,
get_thursday()
,
get_timestamp()
,
get_timezone()
,
get_tomorrow()
,
get_tuesday()
,
get_tz()
,
get_wednesday()
,
get_yesterday()
,
modify()
Magic methods summary
Magic methods used from ICanBoogie\DateTime\Shared
format_as_atom()
,
format_as_cookie()
,
format_as_date()
,
format_as_db()
,
format_as_iso8601()
,
format_as_number()
,
format_as_rfc1036()
,
format_as_rfc1123()
,
format_as_rfc2822()
,
format_as_rfc3339()
,
format_as_rfc822()
,
format_as_rfc850()
,
format_as_rss()
,
format_as_time()
,
format_as_w3c()
Constants summary
Constants inherited from ICanBoogie\DateTime
Properties summary
Magic properties
public read-only
$tomorrow
: ICanBoogie\ImmutableDateTime
A new instance representing the next day. Time is reset to 00:00:00.
public read-only
$yesterday
: ICanBoogie\ImmutableDateTime
A new instance representing the previous day. Time is reset to 00:00:00.
public read-only
$monday
: ICanBoogie\ImmutableDateTime
A new instance representing Monday of the week. Time is reset to 00:00:00.
public read-only
$tuesday
: ICanBoogie\ImmutableDateTime
A new instance representing Tuesday of the week. Time is reset to 00:00:00.
public read-only
$wednesday
: ICanBoogie\ImmutableDateTime
A new instance representing Wednesday of the week. Time is reset to 00:00:00.
public read-only
$thursday
: ICanBoogie\ImmutableDateTime
A new instance representing Thursday of the week. Time is reset to 00:00:00.
public read-only
$friday
: ICanBoogie\ImmutableDateTime
A new instance representing Friday of the week. Time is reset to 00:00:00.
public read-only
$saturday
: ICanBoogie\ImmutableDateTime
A new instance representing Saturday of the week. Time is reset to 00:00:00.
public read-only
$sunday
: ICanBoogie\ImmutableDateTime
A new instance representing Sunday of the week. Time is reset to 00:00:00.
Magic properties used from ICanBoogie\DateTime\Shared
$as_iso8601
,
$day
,
$hour
,
$is_empty
,
$minute
,
$month
,
$second
,
$year
Magic properties used from ICanBoogie\DateTime\Readers
$as_atom
,
$as_cookie
,
$as_date
,
$as_db
,
$as_number
,
$as_rfc1036
,
$as_rfc1123
,
$as_rfc2822
,
$as_rfc3339
,
$as_rfc822
,
$as_rfc850
,
$as_rss
,
$as_time
,
$as_w3c
,
$immutable
,
$is_dst
,
$is_friday
,
$is_future
,
$is_local
,
$is_monday
,
$is_past
,
$is_saturday
,
$is_sunday
,
$is_thursday
,
$is_today
,
$is_tuesday
,
$is_utc
,
$is_wednesday
,
$mutable
,
$quarter
,
$timestamp
,
$timezone
,
$tz
,
$week
,
$weekday
,
$year_day