strtotime('today') returning incorrect time?

If you want strtotime() to return a timestamp relative to UTC (00:00:00 UTC instead of e.g. 00:00:00 UTC+2, if your system is set to a timezone with an offset of 2 hours against UTC/GMT), you need to specify that:

$today = strtotime('today UTC');

GMT (+0) time

echo $today = strtotime('today GMT');
echo "<br>" . $today = date("d-m-Y H:i:s", $today);

We expect that your server runs at GMT - that is the best (for maneuvering with time displays later). If not, you MUST adjust php.ini set this "date.timezone = GMT".

When you get that done, you will see 00:00 with my codes.

Then, you must develop function (ie DisplayDate()) in your script to display dates of your website correctly if

  • youre not in GMT area
  • or/and if you want for your users to see times in their timezone with timezone selection for example.

DisplayDate() should include support for daylight changes also (0, or +1 hour / summer and winter time).


strtotime( $time )

is designed to return a unix timetamp, meaning, it will return the number of seconds since jan 1, 1970. http://www.php.net/manual/en/function.strtotime.php

To get around this, use something like:

$today = date("d/m/Y H:i:s", strtotime('today'));
echo $today;