Tag Archives: PHP

What to do about PHP 5.3′s timezone compaints

If you’ve just upgraded to PHP 5.3, your scripts will probably generate a bunch of errors in this vein:

Warning: date(): It is not safe to rely on the system's timezone settings.
You are *required* to use the date.timezone setting or the
date_default_timezone_set() function. In case you used any of those methods
and you are still getting this warning, you most likely misspelled the
timezone identifier. We selected 'Europe/Helsinki' for '2.0/no DST' instead.

Obviously, the solution is to use the date_default_timezone_set() function, but that means you need to change scripts that ran perfectly well and warning-free previously.

There’s another approach. You can set the default time zone in PHP’s configuration file so that it won’t bother you again (at least on your server). To do so, fine the date.timezone setting in php.ini and change it thusly:

date.timezone = Africa/Maputo

Now the warnings will be gone.

Free Charts Library Development

It’s happened a number of times now that I’m writing a piece of software that needs charts of some sort. Sometimes I’ll need a line chart, sometimes a bar chart, a pie chart, maybe even a Gauss diagram. There are cases that I’ll need a tiny chart that’s not too accurate but shows a tendency, shown as a bitmap (what seems to be called “sparklines”), and sometimes I’ll need a detailed line chart of visitors to a site by month, or number of pushups by day for a member of a gymnasium, or even a world map with data by country. I’ve done projects needing such charts in C#, in PHP, and in Flash.

There’s a problem: there doesn’t seem to be any (quality) free charts package out there. Good packages for PHP are commercial (i.e. JpGraph), but there’s open source stuff available (e.g. pChart) but this is obviously not portable to C#, or Flash. The Google Charts API seems to be the most flexible thing out there, but obviously it’s only available on the web and only for sites that are actually online, i.e. not for intranets. Yet Google Charts is exactly what I want: well thought out, easy to use, very flexible.

Since the backbone of a charts library is some math that allows us to calculate the axes, projection of points on the chart, creating the legend etc., it should be written in a portable way so that it becomes available and reusable in multiple programming languages. Google’s Charts API could be the basis for how charts are specified.

What I’d really like to do is write the algorithms to produce various chart types in pseudocode, so that they could then be implemented in various programming languages, possible then using the Decorator pattern to add features that are language-specific (lots of interesting things can be done with Flash, like mouseovers and zooming).

This’ll be a pet project for a while…

Installing PHP on Windows 7 the Extremely Easy Way

So there I was trying to install PHP 5 on a sparkly new laptop running Windows 7, without the foggiest idea how to make PHP get along with IIS 6.1. Although I had setup PHP plenty of times on Windows XP, IIS 6.1 had a new look that was a bit daunting, so it was off to Google for a step-by-step guide. I ended up finding something better than that. Read more »