©
This document uses PHP Chinese website manual Release
(PHP 5 >= 5.5.0, PHP 7)
This class behaves the same as DateTime except it never modifies itself but returns a new object instead.
$time
= "now"
[, DateTimeZone $timezone
= NULL
]] )$interval
)$format
, string $time
[, DateTimeZone $timezone
] )$datetime
)$modify
)$array
)$year
, int $month
, int $day
)$year
, int $week
[, int $day
= 1
] )$hour
, int $minute
[, int $second
= 0
] )$unixtimestamp
)$timezone
)$interval
)$datetime2
[, bool $absolute
= false
] )$format
)[#1] samundra dot shr at gmail dot com [2015-01-25 04:46:26]
Simple usage of DateTimeImmutable Class:
<?php
$format = "Y-m-d";
$dateString = "2015-01-25";
// Get new DateTimeImmutable Object
$date = DateTimeImmutable::createFromFormat($format,$dateString);
var_dump($date);
// DateTimeImmutable object can be used similar to DateTime object
echo $date->format("Y/m/d");