If you want to create the DateTime object directly from a timestamp use this
<?
$st = 1170288000 // a timestamp
$dt = new DateTime("@$st");
?>
See also: http://bugs.php.net/bug.php?id=40171
date_create说明DateTime date_create ( [string time [, DateTimeZone timezone]] )DateTime DateTime::__construct ( [string time [, DateTimeZone timezone]] ) 参数
Dok
05-Jul-2007 02:52
If you want to create the DateTime object directly from a timestamp use this
artur at jedlinski dot pl
19-Apr-2007 12:47
"String in a format accepted by strtotime()" is not 100% truth - you cannot pass timezone info in the string used as DateTime constructor, while you can do it with strtotime(). It may be a problem if you would like to create a date from GMT time and then display it in your local timezone, for example:
nizar dot jouini at gmail.com
07-Mar-2007 01:05
date_create and other DateTime related functions are included by default only in PHP versions equal and greater than 5.2. | ||