员工时间表时区转换

时间:2019-04-23 15:26:15

标签: php

大家好,我试图将员工时间表从亚洲/马尼拉时区转换为美国/ los_angeles,但由于使用此代码进行转换,所以由于放假时间太长,我出现了错误

$datecon = new DateTime($date[$a].' '.$time[$a], new 
DateTimeZone('Asia/Manila'));
$datecon->setTimezone(new DateTimeZone('America/Los_Angeles'));

错误在这里

  

2019年4月7日,星期日|休息日致命错误:未捕获的异常:   DateTime :: __ construct():无法解析时间字符串(2019年4月7日   OFF(关闭))在位置11(D):在时区中找不到时区   C:\ xampp \ htdocs \ test \ index.php:38中的数据库堆栈跟踪:#0   C:\ xampp \ htdocs \ test \ index.php(38):DateTime-> __ construct('04 / 07/2019   DAY ...',Object(DateTimeZone))#1 {main}被抛出   C:\ xampp \ htdocs \ test \ index.php在第38行

<table class="table table-bordered col-lg-6">
<thead class="thead-dark">
<tr>
    <td>Asia/Manila 
    </td>
    <td>America/Los_Angeles
    </td>
</tr>
</thead>
<tbody>
    <?php 
    $date = array('04/07/2019','04/08/2019','04/09/2019','04/10/2019','04/11/2019','04/12/2019','04/13/2019','04/14/2019','04/15/2019','04/16/2019','04/17/2019','04/18/2019','04/19/2019','04/20/2019');
    $time = array('DAY OFF','DAY OFF','12:00 AM','12:00 AM','12:00 AM','12:00 AM','12:00 AM','DAY OFF','11:00 PM','11:00 PM','11:00 PM','1:00 PM','1:00 PM','DAY OFF');
    $day = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
    $timezone = 'America/Los_Angeles';
    for($a=0; $a < 14; $a++){
    echo '<tr><td>';
    echo $day[$a].', '.$date[$a].'  | <b>'.$time[$a].'</b>';


    $datecon = new DateTime($date[$a].' '.$time[$a], new 
    DateTimeZone('Asia/Manila'));

    $datecon->setTimezone(new DateTimeZone('America/Los_Angeles'));



    echo '<td>';
    echo $day[$a].', '.$date[$a].'</td>';

    echo '</tr>';

    }
    ?>
</tbody>

Result

0 个答案:

没有答案