Date function returning day of month and incorrect time

Asked

Viewed 108 times

2

I am trying to capture the date and time to check the time the user spent without doing any action on the system, but I am having problems with the PHP date function. The code is as follows::

$agora = date("Y-n-j H:i:s");

However, he is returning the day of the month and time incorrectly. Right now it is 19:24 and today it is 14/04, it is returning like this: 2017-4-15 00:23:24, ie, the day of the month is coming with an extra day and the time is coming 00, do not know why. I wonder what I can change in this case so that the function returns me the correct date and time in 24 hours format.

  • 2

    Already checked the time zone on the server and tried with date_default_timezone_set ?

  • That’s right, I downloaded the Apache configuration file set the time zone for my region and solved the problem, vlw by help. Then put the answer in the answer box so I can already mark the question as solved.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.