Hi there,

I have an RSS feed generated by a php script and I need the published date to show but no the time. For some reason my tiny little brain cannot get the code to work without showing everything.

Please can someone help as I am slowly going insane.

The script is:

$dd = substr($d_var['weekday'],0,3) .','. $d_var[mday] .' '.substr($d_var[month],0,3).' '. $d_var[year] .' 09:00:00 GMT';

Thanks in advance.

Facte

Recommended Answers

All 6 Replies

post your required date format.
e.g. default you have $date = '2010-12-31 10:00:00';
Now in what format you would like to display?

post your required date format.
e.g. default you have $date = '2010-12-31 10:00:00';
Now in what format you would like to display?

Thanks for the reply.

Date bit is fine so currently it shows Day then date then time. I just want to get rid of the time.

well just use substr when you output it,
$date = substr($input, 10);
there will always be the same number of characters in the date, so this is probably the simplest "one liner"

To be absolutely sure, you could split the string into the date and time part with explode() :

//Split it and eliminate the time
list($date,) = explode(' ', $date);
//Show the result
echo $date;

On the off change that the date format does not add leading zeros to one digit months/days (I believe the standard does), this would be one way around that and would still work with two digit months and/or days.

then just get rid of the last part where you are appending the time: $dd = substr($d_var['weekday'],0,3) .','. $d_var[mday] .' '.substr($d_var[month],0,3).' '. $d_var[year];

then just get rid of the last part where you are appending the time: $dd = substr($d_var['weekday'],0,3) .','. $d_var[mday] .' '.substr($d_var[month],0,3).' '. $d_var[year];

That was my first thought, but then I assumed the solution wasn't as simple as that. I don't know though, it might be. In which case, we all would look like total idiots for making it so difficult. :P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.