1

I want to get my current system time in computer.

My system time is 7:59PM so I tried to get it by this code

  echo date('Y-m-d H:i:s');

but it gives 2016-12-27 12:59:20

How can I fix this?

I tried solution that adds application/config.php

application/config.php
<?php

defined('BASEPATH') OR exit('No direct script access allowed');

date_default_timezone_set('Asia/Manila');

But it didn't work.

Jomar Gregorio
  • 171
  • 1
  • 3
  • 11

2 Answers2

0

Probably the server is located in a different state or have a different time zone, you should set the time zone same as your location

date_default_timezone_set('America/Los_Angeles');

documentation

Fabio
  • 23,183
  • 12
  • 55
  • 64
0

Try this code:

date_default_timezone_set('Asia/Kolkata');
echo date('h:i A');
Rahul
  • 2,374
  • 2
  • 9
  • 17