Advertisement:

Author Topic: Day Date & Computer Time  (Read 21584 times)

Offline T3CHN0

  • Full Member
  • ***
  • Posts: 630
  • Gender: Male
  • knowledge is power
    • Tarago Pravia Estima
Day Date & Computer Time
« on: January 29, 2011, 02:03:14 PM »
I am using theme Black Rain SMF2.0 RC3
I would think this would work with all 2.0 but just test
and if no good undo the change
you can view it by going to www.aussierampage.com/smf

Just thought I would share what I have done and if someone wants to make a mod for it then go for it.

What I did was simply replace the current date & time with an active day date and computer time
so you don't have to refresh your web page to see current time

simply do this

Find
Code: [Select]
                ', $context['current_time'], '

Replace with
Code: [Select]
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" + ((hours >12) ? hours -12 :hours)
if (timeValue == "0") timeValue = 12;
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " P.M." : " A.M."
document.clock.face.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
function startclock() {
stopclock();
showtime();
}
// End -->
</SCRIPT>
<BODY onLoad="startclock()" bgcolor="#000000"><FORM name="clock"><input type="text" name="face" size=12 value=""></FORM>
                <script type="text/javascript">
<!--

var d_names = new Array("Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday");

var m_names = new Array("January", "February", "March",
"April", "May", "June", "July", "August", "September",
"October", "November", "December");

var d = new Date();
var curr_day = d.getDay();
var curr_date = d.getDate();
var sup = "";
if (curr_date == 1 || curr_date == 21 || curr_date ==31)
   {
   sup = "st";
   }
else if (curr_date == 2 || curr_date == 22)
   {
   sup = "nd";
   }
else if (curr_date == 3 || curr_date == 23)
   {
   sup = "rd";
   }
else
   {
   sup = "th";
   }
var curr_month = d.getMonth();
var curr_year = d.getFullYear();

document.write(d_names[curr_day] + " " + curr_date + "<SUP>"
+ sup + "</SUP> " + m_names[curr_month] + " " + curr_year);

//-->
</script>


Offline Illori

  • Project Manager
  • SMF Master
  • *
  • Posts: 48,085
Re: Day Date & Computer Time
« Reply #1 on: January 29, 2011, 02:06:56 PM »

Offline T3CHN0

  • Full Member
  • ***
  • Posts: 630
  • Gender: Male
  • knowledge is power
    • Tarago Pravia Estima
Re: Day Date & Computer Time
« Reply #2 on: January 29, 2011, 02:35:35 PM »
I like that one as well, but i like where mine is better.
each to there own, mine is just another option.
cheers

Offline T3CHN0

  • Full Member
  • ***
  • Posts: 630
  • Gender: Male
  • knowledge is power
    • Tarago Pravia Estima
Re: Day Date & Computer Time
« Reply #3 on: January 30, 2011, 10:11:48 AM »
using some other code in the link you gave me
plus part of the code I started I now have it looking a little more to what i want
but don't know how to make time and date in one line without the shrink button
in the between.
I will leave it as is for now and will work on it some other time when I have more time again

if you like it use it :)

Code: [Select]
<div id="clock" class="text floatright">Loading...</div>
<script type="text/javascript">
<!--
function refrClock()
{
var d=new Date(); var s=d.getSeconds(); var m=d.getMinutes(); var h=d.getHours(); var am_pm; if (s<10) {s="0"   s} if (m<10) {m="0"   m} if (h>12) {h-=12;am_pm = "pm"}
else {am_pm="am"} if (h<10) {h="0"   h} document.getElementById("clock").innerHTML=h   ":"   m   ":"   s   am_pm; setTimeout("refrClock()",1000); } refrClock();

var d_names = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var d = new Date();
var curr_day = d.getDay();
var curr_date = d.getDate();
var sup = "";
if (curr_date == 1 || curr_date == 21 || curr_date ==31)
   {
   sup = "st";
   }
else if (curr_date == 2 || curr_date == 22)
   {
   sup = "nd";
   }
else if (curr_date == 3 || curr_date == 23)
   {
   sup = "rd";
   }
else
   {
   sup = "th";
   }
var curr_month = d.getMonth();
var curr_year = d.getFullYear();

document.write(d_names[curr_day]   " "   curr_date   "<SUP>"
  sup   "</SUP> "   m_names[curr_month]   " "   curr_year);

//-->
</script>

« Last Edit: January 30, 2011, 10:15:08 AM by techno489 »