Snippets

Adjust server time

Sometimes the time set on your server isn’t accurate to what your local time is. If you can’t change it, you can adjust it yourself.

$today = date('Y-m-d-G');
$today = strftime("%Y-%m-%d-%H", strtotime("$today -5 hour"));

Source: http://css-tricks.com/snippets/php/adjust-server-time/...

Share this snippet

 
  • http://claudiobonifazi.com Claudio

    Why do you subtract exactly 5 hours?

    • http://www.wprecipes.com Jean-Baptiste Jung

      The 5 hours are just an example, for example if your server is on a country with a 5 hour time difference with the country you are in.