PHP日期时间类打开/关闭标记
我正在学习一些教程,遇到了一些我似乎无法理解的事情。我一直在寻找它的道理或意义 在DateTime类的实践中,我遇到了这段代码并尝试了一下。当我使用时,代码不会给我输出PHP日期时间类打开/关闭标记,php,datetime,standards,Php,Datetime,Standards,我正在学习一些教程,遇到了一些我似乎无法理解的事情。我一直在寻找它的道理或意义 在DateTime类的实践中,我遇到了这段代码并尝试了一下。当我使用时,代码不会给我输出 <?php 此标记用于显示一些输出 <?php $publishDate = '2014-08-24 09:14:00'; $localDateTime = new DateTime($publishDate, new DateTimeZone('America/New_York')); $utcDateTi
<?php
此标记用于显示一些输出
<?php
$publishDate = '2014-08-24 09:14:00';
$localDateTime = new DateTime($publishDate, new DateTimeZone('America/New_York'));
$utcDateTime = clone $localDateTime;
$utcDateTime->setTimeZone(new DateTimeZone('UTC'));
?>
<p>The UTC date/time is: <?= $utcDateTime->format("Y-m-d H:i:s") ?></p>
<p>The New York date/time is: <?= $localDateTime->format("Y-m-d H:i:s") ?></p>"
UTC日期/时间为:
纽约的日期/时间是:”
So
纽约的日期/时间是:”
So
纽约的日期/时间是:”
谢谢!我一直盯着屏幕看,我想可能忽略了回声。这很好地解释了。谢谢!我一直盯着屏幕看,我想可能忽略了回声。这很好地解释了!。
<?php
$publishDate = '2014-08-24 09:14:00';
$localDateTime = new DateTime($publishDate, new DateTimeZone('America/New_York'));
$utcDateTime = clone $localDateTime;
$utcDateTime->setTimeZone(new DateTimeZone('UTC'));
?>
<p>The UTC date/time is: <?= $utcDateTime->format("Y-m-d H:i:s") ?></p>
<p>The New York date/time is: <?= $localDateTime->format("Y-m-d H:i:s") ?></p>"
<?php
$date = new DateTime();
echo $date->format('Y-m-d H:i:s');
<p>The UTC date/time is: <?php echo $utcDateTime->format("Y-m-d H:i:s") ?></p>
<p>The New York date/time is: <?php echo $localDateTime->format("Y-m-d H:i:s") ?></p>"