# How to include date and time?

**URL:** <https://www.ruby-forum.com/t/how-to-include-date-and-time/80332>\
**Category:** Radiant CMS\
**Created:** [December 24, 2006, 9:13am UTC](https://www.ruby-forum.com/t/how-to-include-date-and-time/80332 "2006-12-24T09:13:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [December 24, 2006, 9:13am UTC](https://www.ruby-forum.com/t/how-to-include-date-and-time/80332/1 "2006-12-24T09:13:33Z")

</div>

Hello list,

with the radius tag \<r:rfc1123\_date /\> i can include the date and time  
in my pages. However, which way can i modify the output of that radius  
tag?  
Or: Is it possible to include pure Ruby code in the page and layout  
definitions and then style that for an adapted date and time version?

Best regards,  
Andreas S.

---

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [December 24, 2006, 3:01pm UTC](https://www.ruby-forum.com/t/how-to-include-date-and-time/80332/2 "2006-12-24T15:01:59Z")

</div>

Hi Andreas,

That’s trivial. Refer to line 315 of page\_context.rb file. Just for  
reference this is what it says:  
215 # \<r:date [format=“format\_string”] /\>  
316 #  
317 # Renders the date that a page was published (or in the event  
that it has  
318 # not ben modified yet, the date that it was created). The  
format attribute  
319 # uses the same formating codes used by the Ruby +strftime+  
function. By  
320 # default it’s set to ‘%A, %B %d, %Y’.  
321 #  
322 define\_tag ‘date’ do |tag|  
323 page = tag.locals.page  
324 format = tag\_time\_format(tag)  
325 if date = page.published\_at || page.created\_at  
326 date.strftime(format)  
327 end  
328 end

---

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [December 25, 2006, 1:35pm UTC](https://www.ruby-forum.com/t/how-to-include-date-and-time/80332/3 "2006-12-25T13:35:41Z")

</div>

Hi Ruben,

thanks for your explenations. However \<r:date\> is bound to the page  
object, isn’t it?  
What if i just want to include the _actual_ date and time somewhere on  
my pages?

Greetings,  
Andreas S.

---

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [December 25, 2006, 7:04pm UTC](https://www.ruby-forum.com/t/how-to-include-date-and-time/80332/4 "2006-12-25T19:04:04Z")

</div>

Hi Ruben,

thanks for your quick answer!  
Do you know where i can find some documentation (or something like that)  
to learn how to create a new radius tag?

Greetings,  
Andreas S.

Ruben D. Orduz schrieb:

---

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [December 25, 2006, 9:16pm UTC](https://www.ruby-forum.com/t/how-to-include-date-and-time/80332/5 "2006-12-25T21:16:16Z")

</div>

Slighty outdated behaviors way: \<[http://radiantcms.org/blog/](http://radiantcms.org/blog/)  
2006/09/14/how-to-create-global-tags-in-a-plugin/\>

Mental branch, extensions-friendly “Hello World!” tag as an example:  
\<[http://dev.radiantcms.org/radiant/browser/branches/mental/extensions/](http://dev.radiantcms.org/radiant/browser/branches/mental/extensions/)  
examples/hello\_tag?rev=195\>

-jamie

---

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [December 25, 2006, 2:55pm UTC](https://www.ruby-forum.com/t/how-to-include-date-and-time/80332/6 "2006-12-25T14:55:45Z")

</div>

Hi Andreas,

I believe so. If you want to have a context-insensitive date, you could  
either modify the date tag or simply write a new one. In either case, it  
should be fairly straight forward.

Peace.

---

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [December 26, 2006, 5:11pm UTC](https://www.ruby-forum.com/t/how-to-include-date-and-time/80332/7 "2006-12-26T17:11:44Z")

</div>

@Jamie,  
@Ruben,

Thanks!  
It was a good decision to choose Radiant …  
not only because of the elegance of the underlying technology,  
also due to the great community!

Best regards,  
Andreas S.

Jamie W. schrieb:
