date_default_timezone_set showing incorrect time

Viewed 111621

I uploaded the following to a server in the US:

date_default_timezone_set('Asia/Calcutta'); 
echo date("Y-m-d H:i:s"); // time in India

The time displayed is 15 minutes prior to that of the actual time in India.

What am I doing wrong here? What code will always show the time in India accurate to the second?

7 Answers

Its just spelling mistake it should be like this

date_default_timezone_set('Asia/Kolkata');
$timestamp = date("Y-m-d H:i:s");
<?php
                class datashow extends connection{
                    function __construct(){}
                    function showData($id){
                    $iddate=$_SESSION["datesession"];   
                    $qry = "SELECT * FROM data where EnNo='$id' group by Date order by Date DESC";
                    $qry1 = "SELECT * FROM data where EnNo='$id' order by Date DESC";
                    $row=mysqli_query($this->conn, $qry) or die ("query Failed...!");
                    $row1=mysqli_query($this->conn, $qry1) or die ("query Failed...!");
                        while($rec=mysqli_fetch_array($row)){
                            echo "<tr>";
                            echo "<td class='text-center'>".$rec['Date']."</td>";
                            while($rec1=mysqli_fetch_array($row1)){
                                $time1=$rec1["Time"];
                                $time = explode(':', $time1);
                                if($time[0] <= 12){
                                    echo "<td class='text-center' id='timeIn'>".$time[0].":".$time[1].":".$time[2]."</td>";
                                }
                                else if ($time[0] >= 12){
                                    echo "<td class='text-center' id='timeOut'>"."-"."</td>";
                                    echo "<td class='text-center' id='timeOut'>".$time[0].":".$time[1].":".$time[2]."</td>";
                                }
                                }
                                echo "</tr>";   
                            }
                        }
                    function __destruct(){}
                    }
                    if (isset($_REQUEST["btnsub"])){
                    $objcon = new datashow;
                    $objcon->setconnection();
                    $objcon->showData($_REQUEST["btnsub"]);
                    $objcon->CloseCon();
                    }
        ?>
Related