Views: adding "new" image when published date < 1 month In a table view of nodes i want to add a tiny "New" image only when a node is published &lt; 1 month ago. 
Is there a way to achieve this without using PHP? If not, is there an easy way and what PHP should i insert? 
I was hoping for a little module to get the job done, but haven't found anything. 

Thanx, 
Cas
If the list is always going to be in date order, then it can be done without PHP by using a View with an attachment. See this answer for an explanation of how to do that.

If the list is not sorted in date order, PHP may be the way to go. (Though I'd be delighted to be contradicted.) You'll need the Views PHP module installed.


Add the Content: Post date to your list of fields. If you don't want it displayed set the 'Exclude from display' check box. Displayed or not, it's needed.
Add a 'Global: PHP' field to your list of fields. In the Value code box, insert the following snippet:

$interval = time()-  $data-&gt;node_created;
$days = round($interval/(60*60*24));
return $days &lt; 30 ? $days : 0;



This snippet grabs the value of the Post date field from the database query that the view has executed. It then works out the number of seconds difference between the post date and the current time. It converts the seconds into days. If the post is less than 30 days old it returns the number of days as a field value, otherwise it returns 0. (It could just return 0 or 1, but returning the value could be useful in some cases.)


In the No Results Behaviour section check the boxes for 'Count the number 0 as empty', 'Hide if empty' and 'Hide rewriting if empty'. This means when the PHP returns zero, nothing will be displayed.
In the Rewrite Results section, insert whatever output you want when the node is less than 30 days old. In the question you talk about an image, so maybe put in something such as &lt;img src="your image"&gt;.


Additional Notes

If you want to use different date fields etc. you can work out what to put in the PHP by switching on the display of the SQL query in preview. (See the Views settings tab from the main Views page.)

If you want a bit more control over your output, you can use the Output code box. For example the following code will put a red 'new!' label against new fields. When doing this you don't want to also have Rewrite Results set.

&lt;?php if ($value) echo '&lt;p style="color:red"&gt;new!&lt;/p&gt;' ?&gt;


This code checks to see if the result of the earlier PHP code is TRUE (and not zero is TRUE). If it is is displays the red 'new!'