# Re: Date tag oddness

**URL:** <https://www.ruby-forum.com/t/re-date-tag-oddness/89634>\
**Category:** Radiant CMS\
**Created:** [March 21, 2007, 6:40pm UTC](https://www.ruby-forum.com/t/re-date-tag-oddness/89634 "2007-03-21T18:40:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![poopsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@poopsmith](https://www.ruby-forum.com/u/poopsmith)\
**Post date:** [March 21, 2007, 6:40pm UTC](https://www.ruby-forum.com/t/re-date-tag-oddness/89634/1 "2007-03-21T18:40:04Z")

</div>

Walter,

The \<r:date\> tag shows the published\_at date (or created\_at if the  
page hasn’t been published yet).

There was a past conversation where some of us agreed that it would be  
good if the \<r:date\> tag accepted another parameter besides “format”  
to indicate which date to show (published\_at, created\_at or  
updated\_at).

I think it’s a good idea that this new parameter accept another value  
as “now” so it can show the actual date and time. For example, in a  
site I’m working on I had to create a tag to do just that, but it wold  
be a lot better to have this a standard feature.

Is anyone working on it?

Be Radiant!  
Gabriel

---

<div class="post-metadata">

**Author:** ![poopsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@poopsmith](https://www.ruby-forum.com/u/poopsmith)\
**Post date:** [March 27, 2007, 4:32pm UTC](https://www.ruby-forum.com/t/re-date-tag-oddness/89634/2 "2007-03-27T16:32:40Z")

</div>

On Mar 21, 2007, at 1:39 PM, Gabriel L. wrote:

> Is anyone working on it?
> 
> Be Radiant!  
> Gabriel

I couldn’t figure out how to do exactly this, as my Ruby-fu is very  
very young. So I simply defined a new tag called now, as a clone of  
date:

desc %{  
Renders the current date. The format attribute  
uses the same formating codes used by the Ruby @strftime@ function.  
By  
default it’s set to @%A, %B %d, %Y@.

```
 *Usage:*
 <pre><code><r:now [format="format_string"] /></code></pre>

```

}  
tag ‘now’ do |tag|  
page = tag.locals.page  
format = (tag.attr[‘format’] || ‘%A, %B %d, %Y’)  
if date = Time.now  
date.strftime(format)  
end  
end

SInce I used both Copy and Paste, I presume this violates DRY all over  
the place. I’m still learning, and this works for now, but I’d love to  
see how you would create a :now symbol and pass it to r:date.

Walter
