theunicorn Posted June 23, 2009 Share Posted June 23, 2009 Hey yall, I hope you can help me out. I am working on a script that pulls in info from an html form and can't figure out how to format the date and time properly. It shows up as "09-25-2009 20:00" because that is the value the form spits out. How can I change this to read September 25, 2009 8:00 from this bit of code: // make array of date if (eregi('<input type="hidden" name="DateTime" value="(.*)">', $event, $match)); { array_shift($match); foreach ($match as $date) { $position_date = strpos($date, '"'); $date_final = htmlspecialchars(substr_replace($date, '', $position_date)); $date_clean = ereg_replace('é', 'e', $date_final); $date_array[$iter] = $date_clean; $date_clean = date("D d F Y"); ; } } When the actual HTML form output looks like this: <input type="hidden" name="DateTime" value="09-25-2009 20:00"> Is it possible?? Quote Link to comment https://forums.phpfreaks.com/topic/163405-solved-date-format-help/ Share on other sites More sharing options...
.josh Posted June 23, 2009 Share Posted June 23, 2009 $date = "09-25-2009 20:00"; $ta = explode(' ',$date); $tb = explode('-',$ta[0]); $date = $tb[2] . "-" . $tb[0] . "-" . $tb[1] . " " . $ta[1]; $date = strtotime($date); $newDate = date('F d, Y g:i',$date); Quote Link to comment https://forums.phpfreaks.com/topic/163405-solved-date-format-help/#findComment-862182 Share on other sites More sharing options...
theunicorn Posted June 23, 2009 Author Share Posted June 23, 2009 Thanks, i somewhat got it working with that... now the problem is that I need the dates to display for each item I have. It's an event schedule type thing I'm building. Right now it's just displaying the same date (in proper format now!) for each event. How can I get it to display the proper dates for each? Here's my code now: // make array of date if (eregi('<input type="hidden" name="DateTime" value="(.*)">', $event, $match)); { array_shift($match); foreach ($match as $date) { $position_date = strpos($date, '"'); $date_final = htmlspecialchars(substr_replace($date, '', $position_date)); $date_clean = ereg_replace('&#233;', 'e', $date_final); $date_array[$iter] = $date_clean; $date = "$date_clean"; $ta = explode(' ',$date); $tb = explode('-',$ta[0]); $date = $tb[2] . "-" . $tb[0] . "-" . $tb[1] . " " . $ta[1]; $date = strtotime($date); $newDate = date('F d, Y g:i',$date); ; } } And the output: while ($f < $event_number) { print "<item>\n"; print "<title>" . $newDate . " " . $city_array[$f] . " " . $state_array[$f] . " </title>\n"; I had $newDate[$f] but it just made the month "SEPTEMBER" go vertically down the whole list. Quote Link to comment https://forums.phpfreaks.com/topic/163405-solved-date-format-help/#findComment-862211 Share on other sites More sharing options...
theunicorn Posted June 23, 2009 Author Share Posted June 23, 2009 Nevermind I figured it out and got it all working!! thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/163405-solved-date-format-help/#findComment-862230 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.