1

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

2 Answers2

1
  1. Open your php.ini with maybe notepad++, sublime text...
  2. Add this line to the file: date.timezone = "X" Where X is the your time-zone of wish. Get a list of supported timezones here: http://php.net/manual/en/timezones.php

... That should do it.

Mwangi Thiga
  • 1,339
  • 18
  • 22
0

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');
luttkens
  • 1,272
  • 8
  • 16