Menu Close

Month: November 2012

Configuring a SOCKS Proxy and Tunneling With Dante

Obtaining Dante from repository

Dante is a fully functional SOCKS proxy server and as such has many nobs. Fortunately, setting up a basic configuration that will allow tunneling of things like HTTP is relatively simple. If you’re running Debian GNU/Linux, simply run:

# apt-get update
# apt-get install dante-server

Configuring Dante

remember! Dante is a SOCKS host NOT an HTTP proxy, you are going to get all sorts of weird errors if you get this wrong.

The configuration file is locate in

# cat /etc/danted.conf


Convert a UNIX timestamp to a datetime with MySQL


Dates and times can be stored as an integer value as a UNIX timestamp. This isn’t a particularly human readable format but can be converted in MySQL to a datetime value using the FROM_UNIXTIME function.

Dates and times as timestamps

Back when I first started using MySQL and PHP and created an ecommerce system that was used on a number of websites, I decided to store datetimes as a UNIX timestamp for whatever reason. This made it easy to use the PHP date function to format the dates but is not so useful when browsing data in the database or selecting date ranges in a query. I no longer do this and always store date times as a datetime field type now.

Converting integer timestamp to a datetime

In my old ecommerce system there was a table called “orders” with a column called “date_ordered” which was a UNIX timestamp stored as an integer. To convert this to a datetime as part of the SELECT query this needs to be done:

SELECT other fields here, FROM_UNIXTIME(date_ordered)
FROM orders


The integer field will now be represented in the resultset as a datetime string in the format YYYY-MM-DD HH:MM:SS.