Трябва ми корекция за AM PM формат на js часовник

dzone

Registered
[js]var aDays = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
var aMonths = new Array('January','February ','March ','April','May','June','July','August','September','October','November','December' );

function clock()
{
// calculate the offset
// TODO: get the timeoffset in hours from the HTML document
//getTimeOffset();
// the hour offset off the location where they are
var hourOffset = getTimeOffset();
var locOffset = hourOffset * 60 * 60 * 1000;
var NLOffset = 2 * 60 * 60 * 1000;

// define a new date object for the time a person is
// from there we will generate the GMT time
var oLocal = new Date();
// calculate the offset to GMT-time
var off = ( oLocal.getTimezoneOffset() ) * 60 * 1000;
// Make a timestamp of the GMT-time (in milli seconds)
var timeStamp = oLocal.getTime() + off;

// create a new date object. This will be the GMT-time
var oGMT = new Date();
// set the GMT-time
oGMT.setTime( timeStamp );

var oNLLoc = new Date();
var NLTimeStamp = oGMT.getTime() + NLOffset;
oNLLoc.setTime( NLTimeStamp );

// Create the output string for local-time of the person who is watching this site
var sDateTimeL1 = leadingZero(oNLLoc.getHours())
+ ":" + leadingZero(oNLLoc.getMinutes())
+ ":" + leadingZero(oNLLoc.getSeconds());

// put the output between the right html tag
elementInnerHTML('firstloc', sDateTimeL1 );

// Create the outputstring for the GMT time
var sDateTimeL2 = leadingZero(oGMT.getHours())
+ ":" + leadingZero(oGMT.getMinutes())
+ ":" + leadingZero(oGMT.getSeconds());


// Define a new date object for the location where they are (Need a variable of the place. An offset)
var oLoc = new Date();
// we need to know to the offset off the lokation ( hours and + or - )
var newLocTimeStamp = oGMT.getTime() + locOffset;
// set the new time
oLoc.setTime( newLocTimeStamp );
// prepare the output timestring
var sDateTimeL3 = leadingZero(oLoc.getHours())
+ ":" + leadingZero(oLoc.getMinutes())
+ ":" + leadingZero(oLoc.getSeconds());
// replace the output timestring
elementInnerHTML('secondloc', sDateTimeL3 );

// Let the clock tick......... every second!
setTimeout("clock()", 1000);
}

function elementInnerHTML( id , text )
{
if (document.getElementById)
{
x = document.getElementById(id);
if ( x == null ) { return; }
x.innerHTML = '';
x.innerHTML = text;
}
else if (document.all)
{
x = document.all[id];
if ( x == null ) { return; }
x.innerHTML = text;
}
else if (document.layers)
{
x = document.layers[id];
if ( x == null ) { return; }
text2 = '<P CLASS="testclass">' + text + '</P>';
x.document.open();
x.document.write(text2);
x.document.close();
}
}

function getObj(name)
{
if (document.getElementById)
{
this.obj = document.getElementById(name);
this.style = document.getElementById(name).style;
}
else if (document.all)
{
this.obj = document.all[name];
this.style = document.all[name].style;
}
else if (document.layers)
{
this.obj = document.layers[name];
this.style = document.layers[name];
}
}

function takeYear(theDate)
{
x = theDate.getYear();
var y = x % 100;
y += (y < 38) ? 2000 : 1900;
return y;
}

function leadingZero(nr)
{
if (nr < 10) nr = "0" + nr;
return nr;
}

function getTimeOffset()
{
if (document.getElementById)
{
x = document.getElementById('timeoffset');
}
else if (document.all)
{
x = document.all['timeoffset'];
}

if ( x == null ) { return; }

if( x.style.display != 'none')
{
x.style.display = 'none';
}

return x.childNodes[0].nodeValue;
}
//var endDst = new Date();
//endDst.setTime( Date.parse( 'October, 29 2006 03:00:00' ) );
//alert( "Local time:" + endDst.toLocaleString() + " Timestamp: " + endDst.getTime() );
//alert( "GMT time:" + endDst.toGMTString() + " Timestamp: " + endDst.getTime() );

//endDst.setTime( endDst.getTime() + (1000 * 60 ) );
//alert( "Local time:" + endDst.toLocaleString() + " Timestamp: " + endDst.getTime() );


window.onload = clock;

function OpenFile( fileUrl )
{
window.top.opener.SetUrl( fileUrl ) ;
window.top.close() ;
window.top.opener.focus() ;
}[/js]

в момента <span id="firstloc">Bulgaria</span> ми изкарва само 19:35:45 а бих желал да показва 7:35:45 PM
 

Back
Горе