...

View Full Version : preg_replace



mossledossle
11-16-2011, 11:20 AM
This has been driving me mad, how would i rearrange this date:
Tue, 15 Nov 2011 23:53:13 +0000,

To display in the format 15/11/11 23:53

Thanks...

djm0219
11-16-2011, 12:08 PM
print date('d/m/y H:i',strtotime('Tue, 15 Nov 2011 23:53:13 +0000'));

mossledossle
11-16-2011, 12:13 PM
Thanks for the reply, i have this code:


foreach($from as $tweet) {

$data = $tweet->created_at;

$date = print date('d/m/y H:i',strtotime('$data'));

echo '<p>'.$date.'</p>';

}
The date changes (obviously) but is in the previously mentioned format the output from this is just 31/12/69 17:00 1??

mossledossle
11-16-2011, 12:16 PM
I need to use

$tweet->created_at
As the variable for the time...

djm0219
11-16-2011, 12:28 PM
Remove the single quotes in the call to strtotime and the print.


$date = date('d/m/y H:i',strtotime($data));

You should actually be able to use the date object without the intervening variable.


$date = date('d/m/y H:i',strtotime($tweet->created_at));

And to take it one step further and eliminate another variable.



foreach($from as $tweet) {
echo '<p>' . date('d/m/y H:i',strtotime($tweet->created_at)) . '</p>';
}

mossledossle
11-16-2011, 12:31 PM
Thanks very much...

I was only doing it that way to try to work out what was going on, it works now i had single speech marks around the variable in strtotime function.

One other thing, at the end of the output there is a 1? where is this from?


Remove the single quotes in the call to strtotime


$date = print date('d/m/y H:i',strtotime($data));

You should actually be able to use the date object without the intervening variable.


$date = print date('d/m/y H:i',strtotime($tweet->created_at));

djm0219
11-16-2011, 12:57 PM
You haven't removed the print in there. The one is the result of the print statement which you don't need. I used it in my original response simply so you could see what I posted would output.

mossledossle
11-16-2011, 01:19 PM
You haven't removed the print in there. The one is the result of the print statement which you don't need. I used it in my original response simply so you could see what I posted would output.

Thanks for your help, its much appreciated.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum