Grow your CSS skills. Land your dream job.

Last updated on:

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"));

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.


  1. Permalink to comment#

    The preferred way for PHP5 and above is to use:


    A list of the possible values are here:

  2. Yep, definitely use date_default_timezone_set(‘mytimezone’);

  3. Martin
    Permalink to comment#

    earthlink only hosts php 5.0.5 and that time zone changing function is not available… =\


    (PHP 5 >= 5.1.0)

    thank you OP

  4. Permalink to comment#

    Yes i also support to use date_default_timezone_set(‘Your Time Zone’);
    If you have full control over your server then you can change php.ini to locate your timezone.

  5. Syed Zain
    Permalink to comment#

    Great work… i love to read codes from this site.. and reading such content has become my new hobby now a days.. keep it up.

Leave a Comment

Posting Code

  • Use Markdown, and it will escape the code for you, like `<div class="cool">`.
  • Use triple-backticks for blocks of code.
      <h1>multi-line block of code</h1>
      <span>be cool yo.</span>
  • Otherwise, escape your code, like <code>&lt;div class="cool"&gt;</code>. Markdown is just easier though.

Current ye@r *

*May or may not contain any actual "CSS" or "Tricks".