PDA

View Full Version : Local Time Script, PHP vs. SSI



evelands
10-24-2012, 09:22 PM
Hello,

I have a question about your Local Time script
http://www.dynamicdrive.com/dynamicindex6/localtime.htm

Your instructions say to insert this code in the Body:


Current Server Time:<span id="timecontainer"></span>
<script type="text/javascript">
new showLocalTime("timecontainer", "server-ssi", 0, "short")
</script>

… with servermode set to "server-php", "server-asp", or "server-ssi".

My ISP supports PHP but not SSI. So, my body text would be:


Current Server Time:<span id="timecontainer"></span>
<script type="text/javascript">
new showLocalTime("timecontainer", "server-php", 0, "short")
</script>

But, in the header code is this line:


var servertimestring=(servermode=="server-php")? '<? print date("F d, Y H:i:s", time())?>' : (servermode=="server-ssi")? '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->' : '<%= Now() %>'

I see servermode referenced twice here, indicating both php and ssi.

Here is my question: to invoke PHP, do I need to edit this as well?

Also, I am a bit confused why both protocols are referenced in the same line. (Pardon me if I am showing my ignorance here; I come by it naturally).

Thank you for your time and consideration.

Scott Eveland

bernie1227
10-25-2012, 12:03 AM
It's fine, the code is actually using the ternary operator:


? :

It's basically a conditional statement, so if it's php it does some code, otherwise do the ssi code.

djr33
10-25-2012, 03:20 PM
Test out the script. It should work. It's set up to try to do PHP, SSI and ASP, in that order.
In some sense you might want to actually edit the line to only include the particular language you want (in this case PHP) but having the others won't hurt anything.
You should be able to leave it as is and have it work. Check that and let us know if it's not working.

bernie1227
10-25-2012, 07:36 PM
The only problem with modifying it as far as I can see, is that if you switch to using one of the other Languages, it will cease to work entirely.