Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Current Date into .ss template


6 Posts   5236 Views


8 May 2009 at 12:12am Community Member, 197 Posts

I want to insert the time and date into the template in the following format:

echo date('l jS \of F Y h:i:s A');


8 May 2009 at 12:17am (Last edited: 8 May 2009 12:19am), Community Member, 63 Posts

$WhateverYourDateFieldIs.Format(F Y h:i:s A)

EDIT: If you are trying to return the current time and date, the easiest way would probably be to write a function in the controller of page.php

function showTime(){
return date('l jS \of F Y h:i:s A');

and call $showTime where ever in the template.


8 May 2009 at 8:41pm Forum Moderator, 5511 Posts

You can also use the $Now var in templates (which is a DateObject) to return the current date. See for the range of formatting options with $Now


21 May 2009 at 4:29am Community Member, 57 Posts

How do you insert a date on a page to show when it was last updated?


22 May 2009 at 2:57pm (Last edited: 22 May 2009 2:59pm), Forum Moderator, 921 Posts


You can also specify the date format, e.g:

$LastEdited.Format(d M Y h:i a)


21 September 2009 at 2:32pm Community Member, 97 Posts

If you want to use a comma (,) in your date field, see this thread: