Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Krafty

macrumors 601
Original poster
Dec 31, 2007
4,466
343
La La Land
I'm trying a new lockscreen, but the time on it is in 24HR format. This looks like the JavaScript file for it. Could anyone convert it to 12HR, please?

http://cl.ly/65204df146c84d06cbc1
PHP:
function init ( )
{
  timeDisplay = document.createTextNode ( "" );
  document.getElementById("hours").appendChild ( timeDisplay );
  document.getElementById("minutes").appendChild ( timeDisplay );
  document.getElementById("seconds").appendChild ( timeDisplay );
}

function updateClock ( )
{
  var currentTime = new Date ( );
  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var currentSeconds = currentTime.getSeconds ( );

  currentHours = ( currentHours < 10 ? "0" : "" ) + currentHours;
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
  
  document.getElementById("hours").firstChild.nodeValue = currentHours;
  document.getElementById("minutes").firstChild.nodeValue = currentMinutes;
  document.getElementById("seconds").firstChild.nodeValue = currentSeconds;
}
 
I'm not the best with js but try this it might work.

function init ( )
{
timeDisplay = document.createTextNode ( "" );
document.getElementById("hours").appendChild ( timeDisplay );
document.getElementById("minutes").appendChild ( timeDisplay );
document.getElementById("seconds").appendChild ( timeDisplay );
}

function updateClock ( )
{
var currentTime = new Date ( );
var currentHours = currentTime.getHours ( );
var currentMinutes = currentTime.getMinutes ( );
var currentSeconds = currentTime.getSeconds ( );
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;

document.getElementById("hours").firstChild.nodeValue = currentHours;
document.getElementById("minutes").firstChild.nodeValue = currentMinutes;
document.getElementById("seconds").firstChild.nodeValue = currentSeconds;
}
 
Try this

function init ( )
{
timeDisplay = document.createTextNode ( "" );
document.getElementById("hours").appendChild ( timeDisplay );
document.getElementById("minutes").appendChild ( timeDisplay );
document.getElementById("seconds").appendChild ( timeDisplay );
}

function updateClock ( )
{
var currentTime = new Date ( );
var currentHours = currentTime.getHours ( );
var currentMinutes = currentTime.getMinutes ( );
var currentSeconds = currentTime.getSeconds ( );
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;

document.getElementById("hours").firstChild.nodeValue = currentHours;
document.getElementById("minutes").firstChild.nodeValue = currentMinutes;
document.getElementById("seconds").firstChild.nodeValue = currentSeconds;
}
 
what about this..... if not i'm not sure i'm guessing now so someone else might be able to help if this doesn't work or i'll have to check it out tomorrow

function init ( )
{
timeDisplay = document.createTextNode ( "" );
document.getElementById("hours").appendChild ( timeDisplay );
document.getElementById("minutes").appendChild ( timeDisplay );
document.getElementById("seconds").appendChild ( timeDisplay );
}

function updateClock ( )
{
var currentTime = new Date ( );
var currentHours = currentTime.getHours ( );
var currentMinutes = currentTime.getMinutes ( );
var currentSeconds = currentTime.getSeconds ( );
var timeOfDay = ( currentHours < 12 ) ? \"AM\" : \"PM\";
var currentTimeString = currentHours + \":\" + currentMinutes + \":\" + currentSeconds + \" \" + timeOfDay;

currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;
currentHours = ( currentHours == 0 ) ? 12 : currentHours;
currentMinutes = ( currentMinutes < 10 ? \"0\" : \"\" ) + currentMinutes;
currentSeconds = ( currentSeconds < 10 ? \"0\" : \"\" ) + currentSeconds;


document.getElementById("hours").firstChild.nodeValue = currentHours;
document.getElementById("minutes").firstChild.nodeValue = currentMinutes;
document.getElementById("seconds").firstChild.nodeValue = currentSeconds;
}
 
if you send me the lock screen theme i'll have a play and see if i can work it out for you if you like
 
what about this...

function init ( )
{
timeDisplay = document.createTextNode ( "" );
document.getElementById("hours").appendChild ( timeDisplay );
document.getElementById("minutes").appendChild ( timeDisplay );
document.getElementById("seconds").appendChild ( timeDisplay );
}

function updateClock ( )
{
var currentTime = new Date ( );
var currentHours = currentTime.getHours ( );
var currentMinutes = currentTime.getMinutes ( );
var currentSeconds = currentTime.getSeconds ( );

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

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

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

var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;

document.getElementById("hours").firstChild.nodeValue = currentHours;
document.getElementById("minutes").firstChild.nodeValue = currentMinutes;
document.getElementById("seconds").firstChild.nodeValue = currentSeconds;
}
 
Well, I decided to use Lock MS. But if you still want the theme I can upload it for you. Thanks for all your effort though.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.