php - PHP 脚本显示的日期和时间与我的笔记本电脑日期和时间不同 我希望脚本显示我的日期和时间
问题描述
这是我的日期和时间的配置文件。
请问,我还可以在哪里编辑以从我的 PC 获取日期和时间?
$config['time_reference'] = 'local';
所以我有这个打印报告的脚本,但日期和时间与我的电脑日期和时间不匹配。下面的代码
<div class="panel-body">
<div id="printableArea" style="margin-left:2px;">
<div class="text-center">
{company_info}
<h3> {company_name} </h3>
<h4 >{address} </h4>
{/company_info}
<h4> <?php echo display('print_date') ?>: <?php echo date("d/m/Y h:i:s"); ?> </h4>
</div>
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th><?php echo display('sales_date') ?></th>
<th><?php echo display('invoice_no') ?></th>
<th><?php echo display('customer_name')?></th>
<th><?php echo display('total_amount')?></th>
</tr>
</thead>
<tbody>
<?php
解决方案
这是获取本地日期/时间的最快方法
$dateTime = new DateTime("NOW", new DateTimeZone('Europe/Amsterdam'));
echo $dateTime->format("d/m/yyyy H:i:s");
此外,您可以使用PHP的本地时间。
希望这可以帮助!
推荐阅读
- php - 如何从外部视图获取 Laravel 刀片 @foreach 循环中的变量
- javascript - Angular platformLocation pushState 不起作用
- spring - 在 Thymeleaf 中获取带有参数的完整 URL?
- c# - 比较大列表
- reactjs - 如何修复 react-redux 中的“TypeError:this.props.messages.map 不是函数”
- maven - 栅格层 - Geotools:java.lang.NoClassDefFoundError:无法初始化类 javax.imageio.ImageIO
- asp.net - 我希望在文本框中输入 EmpId 的基础上,还应填写该特定 emp 表单中存在的所有其他文本框
- python - 如何在 Python 中将 *all* 字符转义为相应的 html 实体名称和数字?
- excel - Excel Sigma 求和 - 二次表达式
- php - Wordpress 帖子页面 - 循环未显示最新帖子