Today I read about how to link to archive.org videos…
Category Archives: Programming
MySQL convert_tz
Today I used the MySQL convert_tz function.
Before I could use named timezones with convert_tz I had to load the timezones.
Loading MySQL timezone data
Turns out MySQL doesn’t load timezone info by default! As you can read about here.
To load MySQL timezone info:
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
PHP DateTimeZone->getOffset()
Today I had to use PHP’s DateTimeZone->getOffset() to get a timezone offset. It needed formatting which I did with:
function timezone_offset() {
$offset = timezone()->getOffset( now() );
$hours = round( abs( $offset ) / 3600 );
$minutes = round( ( abs( $offset ) - $hours * 3600 ) / 60 );
$result = ( $offset < 0 ? '-' : '+' )
. ( $hours < 10 ? '0' : '' ) . $hours
. ':'
. ( $minutes < 10 ? '0' : '' ) . $minutes;
return $result;
}
301 permanent HTTP redirects with Nginx
According to this article:
rewrite ^/store/view/product/(.*) /store/view.jsp?product=$1 permanent;
Setting svn:ignore from the command line
Today I had to lookup how to set svn:ignore from the command line:
$ svn propset svn:ignore [file|folder] [path]
HTML blockquote
Today I was forced to lookup how to treat <blockquote> and <p> elements. It turns out you wrap paragraphs with blockquote, i.e.:
<blockquote><p>...</p></blockquote>
Character encodings in HTML
Today I had to look up all the various ways HTML might nominate a content-type and I found Character encodings in HTML over on Wikipedia which had all the answers…
Set the target frame of a form
Today I had to lookup how to set the target frame of a form.
Basically you set the ‘target’ attribute on the form to the name of the frame you want to target.
PHP DateInterval spec
It was a bit of a trick to find the DateInterval spec hidden away in the constructor doco, not the DateInterval class doco.
| Designator | Description |
|---|---|
| Y | years |
| M | months |
| D | days |
| W | weeks |
| H | hours |
| M | minutes |
| S | seconds |