tqla Posted February 23, 2007 Share Posted February 23, 2007 Hello, I need help with formatting the date in a string. First of all I have this. As you can see, the Date is pulled from mysql. foreach ($galleries as $gallery) { $gallery_id = $gallery['ID']; $gallery_catid = $gallery['CatID']; $gallery_catname = $gallery['CatName']; $gallery_catsubof = $gallery['CatSubOf']; $gallery_title = $gallery['Title']; $gallery_date = $gallery['Date']; etc... This string pulls from the DB and is the output. if ($gallery_content_array[$gallery_catname]) { $gallery_content_array[$gallery_catname] .= '' . $gallery_date . '<br>' . $gallery_venue . '<br>' . $gallery_address .'<br>' . $gallery_city . ', ' . $gallery_state . '<br>' . $gallery_phone . '<br>' . $gallery_url . '<br><br>'; It works fine except that the date reads like this: 2007-03-05 21:00:00 The Palace 1234 5th street Culver City, CA 310-555-1212 I want the date to read like this, " 03-05-2007, 9:00PM" I know that I need to add this somewhere (F j, Y, g:i) but I don't know where. Please help. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/39861-solved-formatting-date-in-a-string-help/ Share on other sites More sharing options...
artacus Posted February 23, 2007 Share Posted February 23, 2007 Look at the other date format thread posted a few hours ago. Quote Link to comment https://forums.phpfreaks.com/topic/39861-solved-formatting-date-in-a-string-help/#findComment-192573 Share on other sites More sharing options...
tqla Posted February 24, 2007 Author Share Posted February 24, 2007 Don't see it. Can you link to it? Quote Link to comment https://forums.phpfreaks.com/topic/39861-solved-formatting-date-in-a-string-help/#findComment-192778 Share on other sites More sharing options...
JBS103 Posted February 24, 2007 Share Posted February 24, 2007 $gallery_date = date("F j, Y, g:i", strtotime($gallery_date)); //March 5, 2007, 9:00 or $gallery_date = date("m-d-Y, g:ia", strtotime($gallery_date)); //3-05-2007, 9:00pm Pick either one, depending on which you wanted. You asked for both. Quote Link to comment https://forums.phpfreaks.com/topic/39861-solved-formatting-date-in-a-string-help/#findComment-192781 Share on other sites More sharing options...
tqla Posted February 24, 2007 Author Share Posted February 24, 2007 Thank you JBS103. That did it. I appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/39861-solved-formatting-date-in-a-string-help/#findComment-192796 Share on other sites More sharing options...
superuser2 Posted February 24, 2007 Share Posted February 24, 2007 Off topic: How did you get your code to be colored like that, without the big box? Quote Link to comment https://forums.phpfreaks.com/topic/39861-solved-formatting-date-in-a-string-help/#findComment-192933 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.