PHP: its 20 minutes past midnight, and somehow when updating the php date does not change. Why did the php god get mad at me?

As I said, its 20 minutes past midnight, and when I check the date using php

as a date ("Ymd"); and date ("Ymd", strtotime ("now"));

I still get the date of previous days. I expected that during coding there will be many errors, but definitely not that. I would not even have it on the list of potential things that could go wrong. I reviewed the browser using SHIFT + update, and also went into system restart mode.

Something went wrong?

+4
source share
5 answers

Are you sure you got the right time? That is, print additional information:

echo date("c") 

This will give you everything, date, time, time zone, etc.

You can set the time zone you want to use with date_default_timezone_set . Here you can find a list of valid time zones .

You can also set the time zone in your php.ini configuration by setting the date.timezone directive .

+1
source

Are you sure the server is running in the same time zone that you expect?

Try also to print the actual time and see what this tells you.

+4
source

Is the time zone on the server set correctly? What about timezone for PHP ?

+1
source

Does the date not change with subsequent updates, or the date did not change at midnight (from 2009-09-06 to 2009-09-07 )?

0
source

yup, all of you people are right. It was a time zone issue. changed it by adding the uncommentation of the date.timezone property to php.ini and adding the required time zone as described in http://www.php.net/manual/en/timezones.php . Thanks guys

0
source

All Articles