DateTime
PHP 手册

DateTime::__construct

(PHP 5 >= 5.2.0)

DateTime::__constructReturns new DateTime object

说明

DateTime::__construct ([ string $time="now" [, DateTimeZone $timezone=NULL ]] )

Returns new DateTime object.

参数

time

String in a format accepted by strtotime(), defaults to "now".

timezone

Time zone of the time.

错误/异常

Emits Exception in case of an error.

范例

Example #1 DateTime::__construct() example

<?php
date_default_timezone_set
('Europe/London');

$datetime = new DateTime('2008-08-03 14:52:10');
echo 
$datetime->format(DATE_ATOM);
?>


DateTime
PHP 手册