0

I am using date() function in the format date('Y-m-d H:i:s'). It shows 2013-11-22 06:26:25 when the actual time is 2013-11-22 11:56:25. My code,

echo    $today = date('Y-m-d H:i:s');
Hanky Panky
  • 46,730
  • 8
  • 72
  • 95
coderaiseR
  • 79
  • 1
  • 4
  • 14

2 Answers2

1

date function will display date according to timezone being set in php.ini configuration file on server.

So please set timezone on your server using date_default_timezone() function

For more details please refer the documentation mentioned in following url

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

Rubin Porwal
  • 3,736
  • 1
  • 23
  • 26
0

first set your time zone using this code

date_default_timezone_set('UTC');

find utc code of your country here

http://www.date-default-timezone-set.com/

then you can use

echo $today = date('Y-m-d H:i:s');
Hanky Panky
  • 46,730
  • 8
  • 72
  • 95