How to compare dates in PHP

php_date_compareHow to actually compare 2 dates in PHP with each other? The question sounds easier than it is.  The first thought that usually comes is the following. We store both dates as strings and compare them.
Preliminary

<?php
$date1 = "2012-1-12";
$date2 = "2011-10-12";

if ($date1 > $date2)
echo "$date1 is newer than $date2";
else
echo "$date1 is older than $date2";
?>

Output:

2012-1-12 is newer than 2011-10-12

At first glance this seems to be a workable solution. But what if the two data is in a different format?

<?php
$date1 = "12-1-12";
$date2 = "2011-10-12";

if ($date1 > $date2)
echo "$date1 is newer than $date2";
else
echo "$date1 is older than $date2";
?>

Output:

12-1-12 is older than 2011-10-12

Now the date in 2012 is declared to be older than the date in 2011, which is of course wrong. However, from PHP’s point of view, this behavior is correct, because two strings were compared […]

How to execute Perl scripts in Notepad++

notepad++_perl_executeA few days ago I already described how to set up the Eclipse development environment for usage with Perl scripts. If you don’t want to use a sledgehammer to crack a nut,  you can also use the Notepad++ editor to relatively comfortably write Perl scripts.
Besides syntax highlighting and intellisense aka auto completion, Notepad++ also offers the possibility to execute Perl scripts directly from the editors interface. However, therefore a one-time setup is necessary, which I want you to briefly explain below.
Step 1 – create test scripts:
perl-skripte_in_npp_ausführen_1  perl-skripte_in_npp_ausführen_2
To be able to check if you have set up everything correctly later, you should definitely first create a small Perl script and save it. Important: Only stored scripts can be executed afterwards. So always save your […]

RadioduinoWRT – a do it yourself webradio

RadioduinoWRTToday I want to present you one of my larger craft projects. This time it is not just about software, but also about the associated hardware. What is it? A web radio!
I like to listen to internet radio stations, but I didn’t want to run my pc only for listening to webradios.  Connecting my phone to my stereo either wasn’t a solution, since I’d rather wear this with me, because I don’t want to run for each SMS / Whatsapp message to the music system. And because I always like to tinker, it was obvious to build a web radio as a standalone device myself.
As this article has become a bit longer, there is a brief overview of the following sections of the article, so that everyone can quickly find what he looks for.

What is the RadioduinoWRT?
Considerations before […]

How to pixelate images using Javascript

Close Pixelate TutorialToday there is again a bit of Javascript code. The exact topic is about how you can pixelate images via Javascript. This has both advantages and drawbacks, which I would like to briefly point out once below.
Advantages:

Pixelation can be done dynamically (Manual effort in your graphics program falls away. Graphics must not be known beforehand.)
The computational power required is outsourced to the client side. In contrast to a server-side solutions (eg using PHP & Imagick), the computational load is distributed to the users. This helps to keep the server load low, if you have a lot of visitors.

Disadvantages:

The pixelation should be used rather as design or graphic effect, since the data is only sent not pixelated to the client. So if you really want to hide faces and picture information the pixelation still needs to be done before delivery […]