I've got my head around content_format() and have the dates displaying the correct date in nodes now.

I also what to add a format_interval() to the end of the date stating 'days to go'.

When I feed format_interval() a CCK date timestamp, it doesn't calculate the correct interval. Is there a way to do this with any of the date.module functions so it displays the correct interval?

Comments

karens’s picture

I'm guessing you're trying to use format_interval() on the formatted output of the date instead of the raw date value. I am adding a new formatter, 'plain', which will be the raw db value, so you should be able to do something like:

print format_interval(content_format('mydate', $node->mydate[0], 'plain'));

The 'plain' formatter is not there yet, that will get added in later today.

karens’s picture

Status: Active » Fixed

I ended up doing this differently. I just committed a fix to add a format_interval formatter and a timestamp formatter. The format_interval formatter runs the date through a theme_date_format_interval() to format the results (and you can override the theme), or you can use content_format and the 'timestamp' formatter to return the raw timestamp and apply format_interval yourself. Or you can get any part of the date object and apply format_interval to it. Everything is explained in the descriptions for the various functions in date.module.

neubreed’s picture

Thanks I'll have a read and then a play..

Cheers,
Ryan

Anonymous’s picture

Status: Fixed » Closed (fixed)