Úprava widgetu z am/pm na 24h format

Chat fóra: a nikdo. Vstup do diskuze online

komonek | pát bře 16, 2012 1:51 pm

Úprava widgetu z am/pm na 24h format

ahoj, nevíte prosím někdo jak upravit tento kod, pro změnu amerického času na evropský? děkuji

function updateClock ( )
{
var currentTime = new Date ( );

var currentSeconds = currentTime.getSeconds ( );
var currentMinutes = currentTime.getMinutes ( );
var currentHours = currentTime.getHours ( );

var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

currentHours = ( currentHours == 0 ) ? 12 : currentHours;

currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
currentHours = ( currentHours < 10 ? "0" : "" ) + currentHours;

var currentTimeString = currentHours + ":" + currentMinutes;

var currentTime1String = ":" + currentSeconds + timeOfDay;

document.getElementById("clock1").firstChild.nodeValue = currentTimeString;
document.getElementById("clock2").firstChild.nodeValue = currentTime1String;
iPad 4 - 64GB, white, iOS 8.1
iPhone 5S - 64GB, gold, iOS 8.1
appleTV 3th gen.
iPhone expert
iPhone expert
 
Příspěvky: 128
Registrován:
čtv říj 02, 2008 7:16 am

Uživatelský avatar patricius | pát bře 16, 2012 3:08 pm

Re: Úprava widgetu z am/pm na 24h format

Overené funguje
Posledné dva riadky sa vzťahujú už na tvoj dokument, podľa toho ako más jednotlivé polia označené.
Kód: Vybrat vše
function updateClock() {

   var currentTime = new Date();
   var currentSeconds = currentTime.getSeconds();
   var currentMinutes = currentTime.getMinutes();
   var currentHours = currentTime.getHours();   
   
   currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
   currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
   currentHours = ( currentHours < 10 ? "0" : "" ) + currentHours;

   var currentTimeString = currentHours + ":" + currentMinutes;
   var currentTime1String = ":" + currentSeconds;
   
   document.getElementById("clock1").firstChild.nodeValue = currentTimeString;
   document.getElementById("clock2").firstChild.nodeValue = currentTime1String;
   }
iPhone 3G 16GB | iPhone 3GS 16GB | iPhone 4 16GB iOS 5.0.1

Asus N53sv SSD 120GB, HDD 640GB, GeForce GT540M 1GB, i5 2410M SB, 6GB RAM
Host
Host
 
Příspěvky: 60
Registrován:
úte říj 12, 2010 5:56 pm
Bydliště: Trnava (SR)

Prehľad diskusií na forum.iphone.cz

* indicates required

Zpět na iPhone témata, ikony, tapety, fonty

Kdo je online

Uživatelé procházející toto fórum: Google [Bot]

cron