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? Link to comment https://forums.phpfreaks.com/topic/5120-change-mysql-date-output-in-php-page/ 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. Link to comment https://forums.phpfreaks.com/topic/5120-change-mysql-date-output-in-php-page/#findComment-18189 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] Link to comment https://forums.phpfreaks.com/topic/5120-change-mysql-date-output-in-php-page/#findComment-18199 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.