-1

I am from Bangladesh.I am not getting the right time from this code ?

 <html>
      <head>  
        <title>Server time</title>
      </head>
      <body>
        <p>The time at the server is 
        <?php 
        print date('h:i:s A');
        ?>
        </p>
      </body>
    </html>

Output is:

The time at the server is 08:58:51 PM

But actual time is then 01:58:51 AM

Biddut
  • 418
  • 1
  • 6
  • 17
  • 2
    always use date_default_timezone_set(); for correct time zone. check below link for supported timezones http://php.net/manual/en/timezones.php – prasanna puttaswamy Mar 24 '18 at 20:09
  • 2
    See also [`date_default_timezone_set()`](http://php.net/manual/en/function.date-default-timezone-set.php). – Syscall Mar 24 '18 at 20:09
  • 1
    Possible duplicate of [Timezone conversion in php](https://stackoverflow.com/questions/2505681/timezone-conversion-in-php) – aidinMC Mar 24 '18 at 20:11
  • Possible duplicate of [PHP date(); with timezone?](https://stackoverflow.com/questions/20288789/php-date-with-timezone) – versvs Mar 24 '18 at 20:18
  • if you use your server for use in your own country, you might wanna move it for faster response as well :) looks like the server is on another continent :P – Medda86 Mar 24 '18 at 20:19
  • Probably your os webserver time is not set up properly. – Gooner Mar 24 '18 at 20:19
  • How to set web server time? – Biddut Mar 24 '18 at 20:20

1 Answers1

1

Always use date_default_timezone_set() function for correct time in your script In your case use like this

<?php
    date_default_timezone_set("Asia/Dhaka");
    echo date_default_timezone_get();
?>