Dates in PHP-MYSQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vctor
Forum Newbie
Posts: 1
Joined: Thu Apr 25, 2002 7:59 pm
Contact:

Dates in PHP-MYSQL

Post by vctor »

how do you change the date from MYSQL's YYYY-MM-DD to lets say March 3 or so? :?:
User avatar
Ruiser
Forum Newbie
Posts: 8
Joined: Wed Apr 24, 2002 11:04 pm
Contact:

Post 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.
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post 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.
lc
Forum Contributor
Posts: 188
Joined: Tue Apr 23, 2002 6:45 pm
Location: Netherlands

Post 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.
User avatar
groovemaneuver
Forum Newbie
Posts: 2
Joined: Thu May 16, 2002 3:08 am
Location: Honolulu, HI

Post 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!
Post Reply