如何在PHP中打印正确的日期

Hi i am trying to display current date using php code when i run my code it is displaying 1 day back date why it is happening in my code how can i solve this problem

Here is my code

date.php

   <?php
    $myfile=date('m-d-Y');
    echo $myfile;
    ?>

here i am getting output : 09-22-2014 and output should be 09-23-2014

where i am wrong how can i achieve my desired output

Any help will be appreciated

Thanky

You need set default time zone before call date function

date_default_timezone_set('UTC'); $myfile=date('m-d-Y'); echo $myfile;

You probably need to set your timezone:

date_default_timezone_set ( string $timezone_identifier )

http://php.net/manual/en/function.date-default-timezone-set.php

Here is a link to supported timezones:

http://php.net/manual/en/timezones.php

You have to set defauolt timezone first, then you can get the desired data

    date_default_timezone_set("Asia/Kolkata");
    echo date('d-m-Y H:i:s'); //Returns IST 

This will print the current time and date. Note: You can call date function according to your needs.