Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.