Solarpitch Posted January 13, 2007 Share Posted January 13, 2007 Hey guys,when I pull the date and time from the DB it displays as "2007-01-09 20:17:40" and I would like it to display as "9th January 2007, 8:20pm". How can I do this after retrieving it from the database . . or even set this as the format when its actually set in the DB in the first place.Thanks! Link to comment https://forums.phpfreaks.com/topic/34020-format-the-date-time-from-the-db/ Share on other sites More sharing options...
Barand Posted January 13, 2007 Share Posted January 13, 2007 [code]<?php$dbdate = '2007-01-09 20:17:40';echo date ('jS F Y', strtotime($dbdate));?>[/code] Link to comment https://forums.phpfreaks.com/topic/34020-format-the-date-time-from-the-db/#findComment-159927 Share on other sites More sharing options...
paul2463 Posted January 13, 2007 Share Posted January 13, 2007 or you could format it straight from the database[code]<?php$query = "SELECT DATE_FORMAT(`date`, '%D %M %Y, %h:%i %p') FROM `table`"; //returns the date in the format of "9th January 2007, 8:20pm"?>[/code] Link to comment https://forums.phpfreaks.com/topic/34020-format-the-date-time-from-the-db/#findComment-159932 Share on other sites More sharing options...
fenway Posted January 13, 2007 Share Posted January 13, 2007 I'm with paul2463 on this one... sorry, Barand ;-) Link to comment https://forums.phpfreaks.com/topic/34020-format-the-date-time-from-the-db/#findComment-159966 Share on other sites More sharing options...
Barand Posted January 13, 2007 Share Posted January 13, 2007 Et tu, Fenway? Link to comment https://forums.phpfreaks.com/topic/34020-format-the-date-time-from-the-db/#findComment-160089 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.