MartinaL Posted March 16, 2006 Share Posted March 16, 2006 I have some information which I am displaying on a PHP page from a MySQL database.One of them is a date and it comes back in the format 2006-03-17, but I want it to display to the screen in the format 17 March. Is this possible? Quote Link to comment Share on other sites More sharing options...
txmedic03 Posted March 17, 2006 Share Posted March 17, 2006 Yes. You could enter it into the table as a text field instead of a date field and submit it in the format you wish it to display or you could change it once you retrieve it from the database.[code]<?php$date = "2001-01-05";echo date('M d, Y', strtotime($date));?>[/code]I don't know what your variable name is that gets the date from your database, so just replace $date in the echo line with your date variable name and change the echo to whatever it is you need to do with it. Quote Link to comment Share on other sites More sharing options...
Steveo31 Posted March 17, 2006 Share Posted March 17, 2006 Or you could use the MySQL DATE_FORMAT function. Less PHP work.[a href=\"http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.0/en/dat...-functions.html[/a][code]SELECT DATE_FORMAT(lastDate, '%M %D') AS formatted_date[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.