Set Your Site’s Date/Time Settings On Shared Hosting Using PHP5’s date_default_timezone_set()

By  on  

One annoyance with putting my customer's site on shared hosting is not being able to control the date and time on the hosting server. Sure, I could simply host with a local company but that's not always the most cost-effective option.

I use a new function to PHP5, the date_default_timezone_set() function, which allows you to set your time zone. The obvious requirement is PHP5. PHP4 is no longer supported so I look forward to seeing more servers hosting PHP5.

date_default_timezone_set('America/Chicago');

Check out the full list of time zones to see which one you should use.

Recent Features

  • By
    9 Mind-Blowing Canvas Demos

    The <canvas> element has been a revelation for the visual experts among our ranks.  Canvas provides the means for incredible and efficient animations with the added bonus of no Flash; these developers can flash their awesome JavaScript skills instead.  Here are nine unbelievable canvas demos that...

  • By
    An Interview with Eric Meyer

    Your early CSS books were instrumental in pushing my love for front end technologies. What was it about CSS that you fell in love with and drove you to write about it? At first blush, it was the simplicity of it as compared to the table-and-spacer...

Incredible Demos

Discussion

  1. Steve

    Learned this the hard way. Hey – worked in 4.x?? Wot?? Since in live where there is no daylight savings time ever, real fubar…

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!