PHP: Determine the Quarter for a timestamp

PHP’s date and strftime functions are great for retreiving date-related info formatting them. The only thing missing is a way to determine the quarter (Q1-Q4) for a timestamp. Here’s a very short function that will return the quarter for a timestamp: /** * Return the quarter for a timestamp. * @returns integer */ function quarter($ts) […]

PHP: Replace \u characters in json string

In PHP, if you JSON-encode a string that contains accented characters, the result contains unicode sequences (for example: \u00e9 represents the é character). <?php $string = 'åbcdéfg'; print json_encode($string) . "\n"; ?> Running this gives the following output: "\u005e5bcd\u00e9fg" If you want to replace the unicode sequences back to their character representation, here’s what you […]

Configuring DiskStation for multiple websites

The Synology DiskStation comes with the Apache webserver. The “Web Station” functionality allows you to host a website. You can even run multiple virtual hosts. These “default” virtual hosts, however, cannot be configured in detail. But it is very well possible to host multiple websites on a single DiskStation, while still being able to configure […]