A small block that displays the days after a certain date.

$day = 30;
$month = 12;
$year = 1969;
$age= ((int)((mktime (0,0,0,$month,$day,$year) - time(void))/86400) * -1 );
print ("My age in days is " . $age . );

Comments

ionmedia’s picture

if we have nodes typeA with date field 'field_date_a' and typeB with field 'field_additional_info' and we want to display in block on page typeB 'field_additional_info' only if time < (or >) 'field_date_a' how we can do it?

at 1st, from full and teaser views of typeB we disable 'field_additional_info'
2nd, create block with custom php code and setup to display him only on specific address /typeB/*
3rd and most hard to build snippet for this block
i don't know php, but i want to understand how it works
we need function to know value of 'field_date_a' (we assume, that we have only one page typeA and many pages typeB, so array from 'field_date_a' will have only one value)

please, help me to understand how it works

markdavidzahn’s picture

I'm looking to do something kind of specific that I think may be close to this but I can't get it to work on my own. I'm starting a blog documenting the life of my child. I want to be able to put into the template for a blog node that the particular node was written on "Day X" of my child's life, so the fixed date would be the date of birth and instead of using today's date, the date the node was created.

Any thought on how to accomplish this?