Page 1 of 1

Dates in PHP-MYSQL

Posted: Thu Apr 25, 2002 7:59 pm
by vctor
how do you change the date from MYSQL's YYYY-MM-DD to lets say March 3 or so? :?:

Posted: Thu Apr 25, 2002 11:01 pm
by Ruiser
Check out http://www.mysql.com/doc/D/a/Date_and_t ... tions.html. Scroll down until you reach the DATE_FORMAT() function.

Posted: Sat Apr 27, 2002 6:18 pm
by qads
if you don't understand that then:

Code: Select all

$date1 = date("j/m/Y");
that should get you date in 28/05/02 format.

Posted: Sun Apr 28, 2002 6:26 pm
by lc
http://www.php.net/manual/en/function.date.php

Or just go look there and create something nice in whatever format you want.

Posted: Thu May 16, 2002 3:08 am
by groovemaneuver
Ruiser wrote:Check out http://www.mysql.com/doc/D/a/Date_and_t ... tions.html. Scroll down until you reach the DATE_FORMAT() function.
I would definitely recommend going with the MySQL date formatting over the PHP formatting. This is not to say anything against PHP's really cool date formatting functions, but rather as a means of increasing your script's performance.

Database engines are programmed to be as fast as possible (it's part of their marketability if they do well on benchmarks). Using a formatted result in a MySQL query will almost always be faster than a result that needs formatting applied to it.

Take some of the load off your PHP engine and take advantage of external speed where it's available :D The result is a faster executing script.

Cheers!