Hi,
Wondering if there is a way to show the current date in a template, instead of just placeholder text saying "put the date here" since users might forget to edit that, and it's a hassle to have to do so. For example:
templates :
[
{
title: 'Foo',
image: 'Bar.jpg',
description: 'Wish this could show the actual date.',
html:
'<p>' +
'put the date here' +
'</p>'
},
]
I found this javascript for outputting the date, but not sure whether/how it can be incorporated into a template to generate the current date dynamically:
var months = new Array(12);
months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";
var current_date = new Date();
month_value = current_date.getMonth();
day_value = current_date.getDate();
year_value = current_date.getFullYear();
document.write("months[month_value] + " " + day_value + ", " + year_value);
Thanks!
Chris
Wondering if there is a way to show the current date in a template, instead of just placeholder text saying "put the date here" since users might forget to edit that, and it's a hassle to have to do so. For example:
templates :
[
{
title: 'Foo',
image: 'Bar.jpg',
description: 'Wish this could show the actual date.',
html:
'<p>' +
'put the date here' +
'</p>'
},
]
I found this javascript for outputting the date, but not sure whether/how it can be incorporated into a template to generate the current date dynamically:
var months = new Array(12);
months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";
var current_date = new Date();
month_value = current_date.getMonth();
day_value = current_date.getDate();
year_value = current_date.getFullYear();
document.write("months[month_value] + " " + day_value + ", " + year_value);
Thanks!
Chris
Re: Showing current date in template
in config.js
CKEDITOR.myDateFunction = function(){
var months = new Array(12);
months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";
var current_date = new Date();
month_value = current_date.getMonth();
day_value = current_date.getDate();
year_value = current_date.getFullYear();
return months[month_value] +" "+ day_value+", "+ year_value;
};
and then in template file call this function
,{
title: 'Foo',
image: 'Bar.jpg',
description: 'Wish this could show the actual date.',
html:
'<p>'+
CKEDITOR.myDateFunction()
+'</p>'
}
Re: Showing current date in template