I am completing a tutorial which can be found here...http://www.elated.com/articles/cms-in-an-afternoon-php-mysql/
I am having problems getting the correct date format into the database. I have successfully add JQuery UI calendar with a format of dateformat: "yy-mm-dd" but I want to add the date in the format "dd-mm-yy"
The UNIX Timestamp always seems to put the year first eg. 2010-04-03
This is a line of code from my PHP extracting the date...
$sql = "SELECT SQL_CALC_FOUND_ROWS *, UNIX_TIMESTAMP(publicationDate) AS publicationDate FROM articles ORDER BY " . mysql_escape_string($order) . " LIMIT :numRows";
This is one adding the date which is the important bit as most of the users will understand the dd-mm-yy format better...
$sql = "INSERT INTO articles ( publicationDate, title, summary, content ) VALUES (FROM_UNIXTIME(:publicationDate), :title, :summary, :content )";
Any help greatly appreciated as I'm at a lose, even after reading part of the PHP Manual.
Many thanks, CD
If the issue is that YY-MM-DD is stored instead of DD-MM-YY, why not reverse it?
list($yy, $mm, $dd) = explode("-", $datestring);
$ddmmyy = "$dd-$mm-$yy";
That's not a unix timestamp. That's a normal MySQL-formatted date/datetime field. A Unix timestamp is just the number of seconds since Jan 1/1970, and looks nothing like a formatted date. e.g.
'2011-10-31 15:01:00' in mysql is 1320094860 in timestamp format
If you want to change the format the date comes out of MySQL in, you can use the DATE_FORMAT()
function