Dates Separation

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
thesimon
Forum Commoner
Posts: 40
Joined: Sun Mar 13, 2005 9:44 pm

Dates Separation

Post by thesimon »

If i store dates in the database in the datetime form of

YYYY-MM-DD HH:MM:SS (which i believe is somehow standard, correct me if im wrong)

How in php once i have taken that date from the database, can i separate the components and store them in separate variables ($year,$month,$day...)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

If it really does come out of the database in that exact format just a substr() should do it....
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

DATE_FORMAT() works wonders.
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

re:

Post by harrisonad »

read the PHP manual on how to use date() function
Post Reply