/    Sign up×
Community /Pin to ProfileBookmark

print time only

I want to print only the time and not to update every second

[code=php]<?php
// Module //
/**
* @ Copyright (C) 2004 mplampla.com
* @ Autor : MplaMpla.com ( Nikolas Tryfonos )
* @ URL: MplaMpla.com
**/

defined( ‘_VALID_MOS’ ) or die( ‘Direct Access to this location is not allowed.’ );

global $prefix, $dbi,$mosConfig_live_site;

$table_width = $params->get( ‘table_width’ );
if ($table_width) $table_width=” width=”$table_width” “;
$align = $params->get(‘align’);
if ($align) $align = “align=”$align””;

$moduleclass_sfx = $params->get( ‘moduleclass_sfx’, ” );
if ($moduleclass_sfx) {
$class=”class=”moduletable$moduleclass_sfx””;
} else {
$class=”class=”mod_WorldTime””;
}
$clockFaceColor = $params->get( ‘clockFaceColor’, ‘#ffffff’ );
$clockFaceBackgroundColor = $params->get( ‘clockFaceBackgroundColor’, ‘#060A6A’ );

$content.=time_js_content();
$content.=”<form name=”jtime” action=”javascript:void(0)”>”;
$content.=”
<style type=”text/css”>
.mod_WorldTime {
font-style: normal;
}
.mod_WorldTime_Img {
border-bottom: 4px solid $clockFaceBackgroundColor;
}
.mod_WorldTime_Face {
margin-top: 4px;
font-family: Arial;
font-size: 20px;
font-style: normal;
font-weight: bold;
color: $clockFaceColor;
background-color: $clockFaceBackgroundColor;
}
</style>”;
$content.=”<table $align cellspacing=”0″ cellpadding=”0″ $table_width $class><tr><td>”;
$content.=”<table class=”mod_WorldTime_Face” border=”0″ cellspacing=”0″ cellpadding=”0″ align=”center”>”;

$content.=”<tr><td class=”mod_WorldTime_Img”><img name=’timeImage’ id=’timeImage’ src=”$mosConfig_live_site/modules/WorldTime/xBeirut.gif” hspace=1 vspace=1 alt=”Location” width=”140″/></td></tr>”;

$content.=”<tr><td width=”100%” align=”center” height=”24″>”;
$content.=”<script language=”JavaScript” type=”text/javascript”>
if (document.all||document.getElementById)
document.write(‘<span id=”worldclock” class=”mod_WorldTime_Face”></span><br>’)
zone=0;
isitlocal=true;
ampm=”;
// —
function getWTCookieVal (offset) {
var endstr = document.cookie.indexOf (“;”, offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function FixWTCookieDate (date) {
var base = new Date(0);
var skew = base.getTime(); // dawn of (Unix) time – should be 0
if (skew > 0) // Except on the Mac – ahead of its time
date.setTime (date.getTime() – skew);
}
function GetWTCookie (name) {
var arg = name + “=”;
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getWTCookieVal (j);
i = document.cookie.indexOf(” “, i) + 1;
if (i == 0) break;
}
return null;
}
function SetWTCookie (name,value,expires,path,domain,secure) {
document.cookie = name + “=” + escape (value) +
((expires) ? “; expires=” + expires.toGMTString() : “”) +
((path) ? “; path=” + path : “”) +
((domain) ? “; domain=” + domain : “”) +
((secure) ? “; secure” : “”);
}
function DeleteWTCookie (name,path,domain) {
if (GetWTCookie(name)) {
document.cookie = name + “=” +
((path) ? “; path=” + path : “”) +
((domain) ? “; domain=” + domain : “”) +
“; expires=Thu, 01-Jan-70 00:00:01 GMT”;
}
}
//– Selects an item in the list whose value equals theValue
function selWTListItem(theList,theValue,img)
{
var index=-1
for (var i = 0; i < theList.length; i++) {
if (theList.options[i].value == theValue ) {
theList.options[i].selected = true
index=i
} else {
theList.options[i].selected = false
}
}
if ( index > -1 ) { theList.selectedIndex=index }
if (img)
lstWL_img_swap(theList.options[index].label,theList.options[index].value,theList.options[index].text, img)
}

function getWTSelItem(theList)
{
var index=-1
for (var i = 0; i < theList.length; i++) {
if (theList.options[i].selected == true) {
if ( index > -1 ) { theList.selectedIndex=index }
return theList.options[i].value
}
}
return null
}
function lstWL_img_swap(name,url,alt,myImg) {
if ( (name != “”) && (myImg)){
var src = myImg.getAttribute(‘src’);
var fname = src.substring(src.lastIndexOf(‘/’), src.length);
var sTempSrc = myImg.getAttribute(‘src’).replace(fname, ‘/’+name);
myImg.setAttribute(‘src’, sTempSrc);
myImg.setAttribute(‘alt’, alt);
}
}

// —
function updateclock(z){
zone=z.options[z.selectedIndex].value;
//isitlocal=(z.options[0].selected)?true:false;
isitlocal=false;
now=new Date();
switch(zone)
{
case ‘ 0’:
d1 = new Date(‘Mar 28 01:00:00 EST ‘ + now.getFullYear( ));
d2 = new Date(‘Oct 31 02:00:00 EST ‘ + now.getFullYear( ));
if ((now >= d1) && (now <= d2))
zone++;
break

case ‘1’:
case ’10’:
case ‘ 1’:
d1 = new Date(‘Mar 28 02:00:00 EST ‘ + now.getFullYear( ));
d2 = new Date(‘Oct 31 03:00:00 EST ‘ + now.getFullYear( ));
if ((now >= d1) && (now <= d2))
zone++;
break
case ‘2’:
d1 = new Date(‘Mar 28 23:59:00 EST ‘ + now.getFullYear( ));
d2 = new Date(‘Oct 31 23:59:00 EST ‘ + now.getFullYear( ));
if ((now >= d1) && (now <= d2))
zone++;
break
case ‘-8’:
case ‘-7’:
case ‘-6’:
case ‘-5’:
d1 = new Date(‘Apr 04 12:29:22 EST ‘ + now.getFullYear( ));
d2 = new Date(‘Oct 31 12:29:22 EST ‘ + now.getFullYear( ));
if ((now >= d1) && (now <= d2))
zone++;
break

default:
break
}
}
function WorldClock(){
now=new Date();
ofst=now.getTimezoneOffset()/60;
secs=now.getSeconds();
sec=-1.57+Math.PI*secs/30;
mins=now.getMinutes();
min=-1.57+Math.PI*mins/30;
hr=(isitlocal)?now.getHours():(now.getHours() + parseInt(ofst)) + parseInt(zone);
hrs=-1.575+Math.PI*hr/6+Math.PI*parseInt(now.getMinutes())/360;
if (hr < 0) hr+=24;
if (hr > 23) hr-=24;
ampm = (hr > 11)?”PM”:”AM”;
statusampm = ampm.toLowerCase();
hr2 = hr;
if (hr2 == 0) hr2=12;
(hr2 < 13)?hr2:hr2 %= 12;
if (hr2<10) hr2=”0″+hr2
var finaltime=hr2+’:’+((mins < 10)?”0″+mins:mins)+’:’+((secs < 10)?”0″+secs:secs)+’ ‘+statusampm;
if (document.all)
worldclock.innerHTML=finaltime
else if (document.getElementById)
document.getElementById(“worldclock”).innerHTML=finaltime
else if (document.layers){
document.worldclockns.document.worldclockns2.document.write(finaltime)
document.worldclockns.document.worldclockns2.document.close()
}
setTimeout(‘WorldClock()’,1000);
}
WorldClock();
//–>
</script>”;

$content.=”<div id=”worldclockns” width=100% height=55><div id=”worldclockns2″ width=100% height=45 left=0 top=0 class=”mod_WorldTime_Face”></div></div></td></tr>”;
$content.=”</table></td></tr>”;

$content .= “<tr height=”40″ align=”bottom”><td align=”center”><select valign=”top” class=”inputbox” name=”timelist” size=”1″ onchange=”seltime (this);updateclock(this);”>
<option label=’xAthens.gif’ value=”2″>Athens</option>
<option label=’xBangkok.gif’ value=”7″>Bangkok</option>
<option label=’xBeirut.gif’ value=”2″>Beirut</option>
<option label=’xBuenosAires.gif’ value=”-3″>Buenos Aires</option>
<option label=’xCalgary.gif’ value=”-7″>Calgary</option>
<option label=’xDubai.gif’ value=”4″>Dubai</option>
<option label=’xHongKong.gif’ value=”8″>Hong Kong</option>
<option label=’xHouston.gif’ value=”-6″>Houston</option>
<option label=’xLondon.gif’ value=”0″>London GMT</option>
<option label=’xLondon.gif’ value=” 0″>London BST</option>
<option label=’xNewYork.gif’ value=”-5″>New York</option>
<option label=’xNicosia.gif’ value=”2″>Nicosia</option>
<option label=’xRiyadh.gif’ value=”3″>Riyadh</option>
<option label=’xParis.gif’ value=” 1″>Paris</option>
<option label=’xRome.gif’ value=”1″>Rome</option>
<option label=’xSanFrancisco.gif’ value=”-8″>San Francisco</option>
<option label=’xSydney.gif’ value=”10″>Sydney</option>
<option label=’xTokyo.gif’ value=”9″>Tokyo</option>
</select></td></tr>”;

$content.=”</table>”;
$content.=”<input type=hidden name=”timedef” value=”http://time.yahoo.com/” />”;
$content.=”</form>”;

$content.=”<script type=”text/javascript” language=”JavaScript1.2″>
seltime(document.jtime.timelist,’2′);updateclock(document.jtime.timelist);
</script>”;

function time_js_content() {
global $mosConfig_live_site;
return <<<END_OF_TEXT
<script type=”text/javascript” language=”JavaScript1.2″>
function seltime(timeList,deftime) {
if (typeof deftime == ‘undefined’) { var deftime = null }
var name = “Deftime”;
var myImg = document.getElementById(‘timeImage’);
var val = GetWTCookie(name)
if (deftime == null) {
val = getWTSelItem(timeList)
if (val != null) {
var expdate = new Date ();
FixWTCookieDate (expdate);
expdate.setTime (expdate.getTime() + (168 * 60 * 60 * 1000)); // 24*7 hrs from now
SetWTCookie (name, val, expdate);
selWTListItem(timeList,val,myImg)
}
} else {
if (val == null) {
val = deftime;
}
var expdate = new Date ();
FixWTCookieDate (expdate);
expdate.setTime (expdate.getTime() + (168 * 60 * 60 * 1000)); // 24*7 hrs from now
SetWTCookie (name, val, expdate);
selWTListItem(timeList,val,myImg)
}
}
</script>
END_OF_TEXT;
}
?>
[/code]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@dev123Oct 15.2005 — Do you want to print it from JavaScript or from PHP?
×

Success!

Help @nikolas22t spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...