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, Ed, biapar, Willr, Ingo, swaiba

Current Date into .ss template

Go to End

6 Posts   6744 Views


Community Member, 197 Posts

8 May 2009 at 12:12am

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');


Community Member, 63 Posts

8 May 2009 at 12:17am

Edited: 08/05/2009 12:19am

$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.


Forum Moderator, 5521 Posts

8 May 2009 at 8:41pm

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


Community Member, 57 Posts

21 May 2009 at 4:29am

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


Forum Moderator, 922 Posts

22 May 2009 at 2:57pm

Edited: 22/05/2009 2:59pm


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

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


Community Member, 97 Posts

21 September 2009 at 2:32pm

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