I had a bit of a problem in this area. It was decided to dump existing information to CSV as an intermediary step. The dates are currently stored in YYYY-MM-DD, MySQL DATE format.
A unique condition is that a null value was actually stored as 0000-00-00. I therefore had to return an empty string for this condition, and a formatted date for a valid date.
The standard UNIX_TIMESTAMP provides the right format, but for my time values I had to multiply the result by 1000 to account for milliseconds, as mentioned in svensen's post.
The following is the error I was recieving.
The following is the field as it appears in my SELECT statement.
Error: Could not convert given string 0000-00-00 to a date. (CON-0600, -1606298603-3304)
IF(birthday='0000-00-00','',UNIX_TIMESTAMP(birthday) * 1000)