Jump to content

Javascript "The date is...." Integration Problem


Recommended Posts

I need your help!


I have managed to integrate every aspect of my template except one part.


I have a simple "The date today is..." sentence of text on my header.tpl


The code, as in the index.html file, reads as:


                        <li>The date today is <script language="JavaScript">
function getCorrectedYear(year) {
year = year - 0;
if (year < 70) return (2000 + year);
if (year < 1900) return (1900 + year);
return year;

var lmod = new Date();
var monthname;
var lmonth = lmod.getMonth();
if (lmonth == 0) monthname = "January";
if (lmonth == 1) monthname = "February";
if (lmonth == 2) monthname = "March";
if (lmonth == 3) monthname = "April";
if (lmonth == 4) monthname = "May";
if (lmonth == 5) monthname = "June";
if (lmonth == 6) monthname = "July";
if (lmonth == 7) monthname = "August";
if (lmonth ==  monthname = "September";
if (lmonth == 9) monthname = "October";
if (lmonth == 10) monthname = "November";
if (lmonth == 11) monthname = "December";

var yearstr = getCorrectedYear(lmod.getYear());

var outstr = lmod.getDate() + " " + monthname + " " + yearstr;
// -->


However, whenever I add the above code to my header.tpl and upload it, any page of my WHMCS just doesn't load and remains as a white page. When I remove this code, however, the site loads correctly.


Can someone help me and tell me how I can get the date code to work on WHMCS?!



Link to comment
Share on other sites

By the way, I also tried putting this into my header.tpl :


The date today is <script type=text/javascript src="js/date.js"></script></li>                        


and I put the code from the above post into the file date.js .


This did not work either - I just don't know what I am doing...

Link to comment
Share on other sites

In any of your tpl files you can simply use {$todaysdate} to get the current date


Thank you!


However, do you know how I can use this on my index page etc?

I want the date to display in the same format - currently the WHMCS pages display it differently to the other pages.


How can I use this code on my non-WHMCS pages? I put it into my terms page and renamed it terms.php but it does not display how it does on WHMCS pages. It just says {$todaysdate} instead of the date!


Any ideas how I can get the same format of date on the other pages, such as my index, terms, privacy pages etc?

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated