Jump to content

[SOLVED] Date Format Help!


theunicorn

Recommended Posts

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('&#233;', '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??

 

Link to comment
https://forums.phpfreaks.com/topic/163405-solved-date-format-help/
Share on other sites

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('&#38;#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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.