首页 > 解决方案 > 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

标签: phpdatetimetimezone

解决方案


这是获取本地日期/时间的最快方法

$dateTime = new DateTime("NOW", new DateTimeZone('Europe/Amsterdam'));

echo $dateTime->format("d/m/yyyy H:i:s");

此外,您可以使用PHP的本地时间。

希望这可以帮助!


推荐阅读