I want to insert the time and date into the Page.ss template in the following format:
echo date('l jS \of F Y h:i:s A');
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
I want to insert the time and date into the Page.ss template in the following format:
echo date('l jS \of F Y h:i:s A');
$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.
You can also use the $Now var in templates (which is a DateObject) to return the current date. See http://doc.silverstripe.com/doku.php?id=date for the range of formatting options with $Now
How do you insert a date on a page to show when it was last updated?
$LastEdited
You can also specify the date format, e.g:
$LastEdited.Format(d M Y h:i a)
If you want to use a comma (,) in your date field, see this thread: