Time zone in wamp

Shubham

I am using wamp in window 8 and in this i am using the time zone Asia/Calcutta but the problem is that when i tried to get the current date and time then it gives me one day after date for ex: today is 28 june it gives me 29 june i check that my default time zone is Asia/Calcutta

Code is

$currentDate = strtotime("now");    
$starttime=date("Y-m-d H:i:s", $currentDate);

Then it gives me the out put: 2014-06-29 04:17:02

I am not able to get this and i have also changed the php.in

luttkens

You should use DateTime class instead

$now = new DateTime();
echo $now->format('Y-m-d H:i:s');

The printed date will be in the default timezone, based on php.ini or system default. To set a specific timezone, do this:

$now->setTimezone(new DateTimeZone('Asia/Calcutta'));
echo $now->format('Y-m-d H:i:s');

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related