localhost和webhost在PHP中的输出不一样

时间:2015-10-21 02:43:12

标签: php localhost web-hosting

对不起我是PHP的初学者,我想请求帮助为什么在localhost中我完善了我想要的过程,但是当我将它上传到我们的webhost时,它是不同的输出过程,同样的日期。

我来自菲律宾(GMT + 8)。

我在流程中输入的示例: 今天的日期输入日期,所以状态将为NEW - FRESH - ACTIVE 但是当我在webhost端输入时,状态将像DORMANT,WINBACK,INACTIVE。

截图:
Localhost(这是完美的过程): enter image description here

Webhost视图(不正确): enter image description here

编辑:我添加了香港时区在webhost中仍有问题 这是我的代码:

<?php

date_default_timezone_set('Hongkong');
if(isset($_POST['submit']))
{
    $dateRegistration = mysql_real_escape_string($_POST['dateRegistration']);
    $dateStarted = mysql_real_escape_string($_POST['dateStarted']);
    $dateExpiration = mysql_real_escape_string($_POST['dateExpiration']);
    $accType = mysql_real_escape_string($_POST['accType']);
    $subsType = mysql_real_escape_string($_POST['subsType']);
    $status = mysql_real_escape_string($_POST['status']);

    //declartion
    $accType = "NEW";
    $subsType = "FRESH";
    $status = "ACTIVE";
    $color = "<th style=\"color: #cccc00;\">&nbsp;&nbsp;&nbsp;";
    #7f7f00

    //Equation 
    $dateExpiration = date('Y/m/d', strtotime($dateStarted. '+ 30 days'));

    //$dateRegExisting = date('Y/m/d', strtotime($dateRegistration. '+30 days'));


    if (strtotime($dateRegistration)<strtotime('-30 days')) {
        $accType = "EXISTING";
        $subsType = "RENEWAL";
        $color = "<th style=\"color: #7f7f00;\">&nbsp;&nbsp;&nbsp;";

    } 



    if (strtotime($dateStarted)<strtotime('-30 days')) {
        $subsType = "FOR RENEWAL";
        $accType = "EXISTING";
        $status = "INACTIVE";
        $color = "<th style=\"color: red;\">&nbsp;&nbsp;&nbsp;";
    }


      if (strtotime($dateStarted)<strtotime('-90 days')) {
        $accType = "DORMANT";
        $subsType = "FOR WINBACK";
        $status = "INACTIVE";
        $color = "<th style=\"color: red;\">&nbsp;&nbsp;&nbsp;";

    }


}


  $date1 = date('Y/m/d');

  echo "<br/>";
  echo "<br/>";
  echo "Today is: ".$date1;


  ?>


  <html>

  <head>

  <title>Add New Subscriber | Customer Information System</title>
  <script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
  <!-- Bootstrap core CSS -->

  <title>Title goes here</title>


 <script src="http://cdn.jsdelivr.net/webshim/1.12.4/extras/modernizr-custom.js"></script>
 <script src="http://cdn.jsdelivr.net/webshim/1.12.4/polyfiller.js">   </script>
<script>

webshims.setOptions('waitReady', false);
webshims.setOptions('forms-ext', {types: 'date'});
webshims.polyfill('forms forms-ext');

</script>

<style>
table, th, td {
border: 1px solid black;
}

#expiration {

color: red;
 }

</style>
</head>

<body>


<form action="" method="POST">

<br/>
<br/>
<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label><strong>Date of Registration:</strong></label>
<input type="date" id="date" name="dateRegistration" placeholder="Date of Reg">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label><strong>Start of Subscription:</strong></label>
<input type="date" id="date" name="dateStarted" placeholder="Start ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<input type="hidden" id="expiration" name="dateExpiration" placeholder="Expiration" ></font>
<br/>
<br/>
<input type="submit" name="submit" value="Submit" style="margin-left: 25em;">
<br/>
<br/>
<br/>
<br/>
<table style="margin-left: 7em;">

    <tr>
        <th>&nbsp;&nbsp;Date of Registration&nbsp;&nbsp;</th>
        <th>&nbsp;Start of Subscription&nbsp;&nbsp;&nbsp;</th>
        <th>&nbsp;&nbsp;Expiration&nbsp;&nbsp;&nbsp;&nbsp;</th>
        <th>&nbsp;&nbsp;Account Type&nbsp;&nbsp;&nbsp;&nbsp;</th>
        <th>&nbsp;&nbsp;Subscription Type&nbsp;&nbsp;&nbsp;&nbsp;</th>
        <th>&nbsp;&nbsp;Status&nbsp;&nbsp;&nbsp;&nbsp;</th>
    </tr>
    <tr>
        <?php
        echo "<th style=\"color: black;\">&nbsp;&nbsp;&nbsp;".$dateRegistration."</th>";
        echo "<th style=\"color: black;\">&nbsp;&nbsp;&nbsp;".$dateStarted."</th>";
        echo "<th style=\"color: black;\">&nbsp;&nbsp;&nbsp;".$dateExpiration."&nbsp;&nbsp;&nbsp;</th>";
        echo $color.''.$accType."</th>";
        echo $color.''.$subsType."&nbsp;&nbsp;&nbsp;</th>";
        echo $color.''.$status."&nbsp;&nbsp;&nbsp;</th>";

        ?>

    </tr>

 </table>
 </form>
 </body>
 </html>

2 个答案:

答案 0 :(得分:0)

可能是您的网络主机系统没有设置当前时间的时间,而是过去的某个时间。您可能希望使用以下方法检查系统时间:

echo date('Y-m-d H:i:s'); exit;

将它放在代码中的第一个php行,检查时间是否与当前时间匹配,然后考虑更改系统时间。

此致

答案 1 :(得分:0)

我有自己的答案,如果没有数据库,我删除了mysql_real_escape_string