Im using $date('Y-m-d H:i:s') to grab date and store it in a database in datetime format, but on some occasions Id prefer to display just Y-m-d or Y-m-d, 2pm as apposed to the full date n time values. Is there any simple way to split the data in the row so I can just grab the first part of it like this?
You can do it from the database, Check out the DATE_FORMAT() function in MySQL
Read up on the Date and Time Functions.
rincewind456 wrote:You can do it from the database, Check out the DATE_FORMAT() function in MySQL
Hmm.. im not sure thats precisely what I want to do- since Im grabbing several pieces of data outta the row all at once.. so I already have $row[date] extracted. What I could do with is something like $row[date][0] which works and displays teh very first character, but I want one that shows the first few.. ideally.. er like $row[date][Y-m-d] (which obviously doesnt work) but thats more the kinda effect Im lookin for.
1st way
create $date =$date(Y-M-D); create $time =$date(h:i:s);
keep it separately in DB
2nd way substr(string, start, length);
substr($row['date'],0,5);
i.e.
$go="christmas"; $result=substr($go, 0, 3);
$result="chr";