enter image description here

Code:

date_default_timezone_set('UTC'); echo date("mdY"); echo "<br>"; echo strtotime("now"); echo "<br>"; echo date("mdY",strtotime("now")); 

Why is the date wrong? php says 23 number, but in fact 24.

  • 3
    date_default_timezone_set('Europe/Moscow'); - Manitikyl
  • 2
    If you need dates of different belts, use DateTime php.net/manual/ru/class.datetime.php - Manitikyl
  • That's what I got fucked up ..., thank you - Vitaly Shebanits
  • Check, all fixed. It should now be 24. - vp_arth

1 answer 1

Check out date_default_timezone_set () , as you wrote above.

If you do not specify a time zone, it is determined by the default settings in php.ini settings