eSnippets.net, a code gallery for creating, saving and sharing all kinds of code snippets.

Adjust Server Time — PHP

Posted On: Saturday, May 17, 2014 at 1:12 AM

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. If your server thought it was 12 midnight, but it was really 7 pm, this will roll the $today variable back five hours to be correct.

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

You need to be logged in to comment! x

rpjs

Joined on Saturday, May 3, 2014
Contributed 29 Snippets

Get Social and Share

Tags