Archive for March, 2009

“Last month” incorrect with PHP Date & strtotime functions

I use a lot of business style reporting in our companies website where displaying figures by month is important. However, at certain points in the year using the PHP date and strtotime functions to pull data from our DB works incorrectly. For example, today and tomorrow (30th & 31st March), using “last month” in the strtotime function will actually return the timestamp for 2nd & 3rd March, not the 27th & 28th February that the developer may have been expecting.

The reason for this? It’s because the Romans were superstitious of even numbers and thus we have a very disorganised calendar system that doesn’t always match up with the decimal and binary way we now work in.

If you do want to get the timestamp of a date that falls in the previous month, the below code should help:

$last = strtotime(date(‘Y-m-01′).’ -1 month’);

This will (at the moment) return the 1st February.

 

Bosch Exxcel WVD24520GB & the child lock

We’ve got a Bosch Exxcel WVD24520GB Washer Dryer and it’s been great – up until now! It has a supposedly “brilliant” feature called a child lock. It is a good idea because you can turn it on and then your children can’t turn the dials or push the buttons and screw up the wash cycle!

Problem is that unless you’ve got too much free time and actually sat there and read the manual from front to back – noone knows how to turn it on and so doesn’t use it. Until the child – in my case my two year old daughter – presses a few buttons and turns it on by accident!

You then got one hell of a task to turn it off. Turns out it’s this easy:

Hold down the clock/time button for five seconds

I just wish I’d been able to find that out without having to read the entire manual from front to nearly the back.