Hi,
I'm trying to add the date/time to my CMSMS site.
I have tried some different .js methods, all work fine on my site without CMCMS, but when I try the same method on a my CMSMS site thery don't work.
Can it done with PHP and HTML? Does anyone know a method of acheiving this?
Many Thanks
Lee
How to add date/time to page
Re: How to add date/time to page
In template you must surround your js with: {literal} ... {/literal}leet8845 wrote: I have tried some different .js methods, all work fine on my site without CMCMS, but when I try the same method on a my CMSMS site thery don't work.
Have you look in plugins section?leet8845 wrote: Can it done with PHP and HTML? Does anyone know a method of acheiving this?
There are current_date or (for pages) created_date, recently_updated and last_modified_by
Alby
Re: How to add date/time to page
Thanks Alby,
I have added the {literal} ... {/literal} tags but I think I am doing wrong somehow;
Any ideas?
Many Thanks
Lee
I have added the {literal} ... {/literal} tags but I think I am doing wrong somehow;
Code: Select all
{literal}<__script__ language="JavaScript" type="text/JavaScript">
function initArray() {
for(i=0;i<initArray.arguments.length; i++)
this[i] = initArray.arguments[i];
}
var isnMonths=new initArray("JANUARY","FEBRUARY","MARCH",
"APRIL","MAY","JUNE",
"JULY","AUGUST","SEPTEMBER",
"OCTOBER","NOVEMBER","DECEMBER");
var isnDays= new initArray("Sun","Mon","Tue","Wed",
"Thu","Fri","Sat","Sun");
today=new Date();
hrs=today.getHours();
min=today.getMinutes();
sec=today.getSeconds();
clckh=""+((hrs>12)?hrs-12:hrs);
clckm=((min<10)?"0":"")+min;
clck=(hrs>=12)?"PM":"AM";
var stnr="";
var ns="0123456789";
var a="";
function getFullYear(d) { // d is a date object
yr = d.getYear();
if (yr < 1000)
yr+=1900;
return yr;
}
</__script>
<__script__>document.write(" "+isnDays[today.getDay()]+", "+isnMonths[today.getMonth()]+" "+today.getDate()+", "+getFullYear(today)+"");</__script>
<__script__>document.write(" "+clckh+":"+clckm+" "+clck+" ");</__script>{/literal}
Many Thanks
Lee
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: How to add date/time to page
smarty has variables built in for the date and time
as well as customcontent
as well as customcontent
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: How to add date/time to page
I have a UDT that I use called servertime that I call in my footer. It puts a "realtime" clock wherever you place it.
The UDT code:
Then call it in your template like this:
Nullig
The UDT code:
Code: Select all
list($sy,$sm,$sd,$sh,$si,$ss) = explode(",", date("Y,n,j,G,i,s"));
$isi = intval($si);
$iss = intval($ss);
$host = $_SERVER['HTTP_HOST'];
echo "
<__script__ type=\"text/javascript\">
<!--
function clock() {
document.write('<span id=\"clock\"></span>');
var server = new Date($sy, $sm, $sd, $sh, $isi, $iss).getTime();
var client = new Date().getTime();
tick(client-server);
}
function tick(diff) {
var d = new Date(new Date().getTime()-diff);
var i = d.getMinutes(); if(i < 10) i='0'+i;
var s = d.getSeconds(); if(s < 10) s='0'+s;
var month_names = ',Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'.split(/,/g);
var clock = document.getElementById(\"clock\");
if(clock) {
clock.innerHTML='Server Time: '+
month_names[d.getMonth()]+' '+d.getDate()+', '+d.getFullYear()+' '+
d.getHours()+':'+i+':'+s;
setTimeout('tick(' + diff + ');', 1000);
}
}
clock();
//-->
</__script>";
Code: Select all
{servertime}
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: How to add date/time to page
Recomended reading for all users: http://smarty.php.net/crashcourse.php
the answer to this post is simply {$smarty.now|date_format}
Now if it doesn't display to your liking, then the smarty docs explain exactly how to change the output.
I recommend a 'recommended reading' or a 'have you read this before you post' section be put up somewhere.
the answer to this post is simply {$smarty.now|date_format}
Now if it doesn't display to your liking, then the smarty docs explain exactly how to change the output.
I recommend a 'recommended reading' or a 'have you read this before you post' section be put up somewhere.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.