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
public static
|
|
public
|
|
public
|
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
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
public
|
|
public
|
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
string |
ATOM
|
#
MutableDateTime::ATOM
|
string |
COOKIE
|
#
MutableDateTime::COOKIE
|
string |
RSS
|
#
MutableDateTime::RSS
|
string |
ISO8601
|
#
MutableDateTime::ISO8601
|
string |
RFC822
|
#
MutableDateTime::RFC822
|
string |
RFC850
|
#
MutableDateTime::RFC850
|
string |
RFC1036
|
#
MutableDateTime::RFC1036
|
string |
RFC1123
|
#
MutableDateTime::RFC1123
|
string |
RFC2822
|
#
MutableDateTime::RFC2822
|
string |
RFC3339
|
#
MutableDateTime::RFC3339
|
string |
W3C
|
#
MutableDateTime::W3C
|
Constants inherited from ICanBoogie\DateTime
Properties summary
Magic properties
public read-only
|
$tomorrow
A new instance representing the next day. Time is reset to 00:00:00. |
public read-only
|
$yesterday
A new instance representing the previous day. Time is reset to 00:00:00. |
public read-only
|
$monday
A new instance representing Monday of the week. Time is reset to 00:00:00. |
public read-only
|
$tuesday
A new instance representing Tuesday of the week. Time is reset to 00:00:00. |
public read-only
|
$wednesday
A new instance representing Wednesday of the week. Time is reset to 00:00:00. |
public read-only
|
$thursday
A new instance representing Thursday of the week. Time is reset to 00:00:00. |
public read-only
|
$friday
A new instance representing Friday of the week. Time is reset to 00:00:00. |
public read-only
|
$saturday
A new instance representing Saturday of the week. Time is reset to 00:00:00. |
public read-only
|
$sunday
A new instance representing Sunday of the week. Time is reset to 00:00:00. |
public read-only
|
$utc
A new instance in the UTC timezone. |
public read-only
|
$local
A new instance in the local timezone. |
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