Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Gadget Help; change 24-hour clock into 12-hours

27 Jan 2016   #1
SylkRode

Windows 7 Home Premium 64-bit
 
 
Gadget Help; change 24-hour clock into 12-hours

I downloaded the StarCraft II Clock from the Windows 7 Desktop Gadget gallery, only to find it's a 24-hour clock and has no settings. How would I change it - presumably by changing its java file - so that it is a 12-hour clock instead?


My System SpecsSystem Spec
.
28 Jan 2016   #2
pbcopter

Windows 7 Ultimate x64 SP1, Windows 8.1 Pro x64, Windows 10 Pro x64
 
 

I do not know if it is possible. You might ask the creator.

However, I like the Preston Clock gadget myself. It can be set up in 12 or 24 hrs.

Windows Gadget: Presto's Sidebar Clock (Preston Hunt)
My System SpecsSystem Spec
31 Jan 2016   #3
SylkRode

Windows 7 Home Premium 64-bit
 
 

Point is, I quite like the look of that clock.
My System SpecsSystem Spec
.

02 Feb 2016   #4
pbcopter

Windows 7 Ultimate x64 SP1, Windows 8.1 Pro x64, Windows 10 Pro x64
 
 

See the next post.


Attached Images
Gadget Help; change 24-hour clock into 12-hours-clk.png 
My System SpecsSystem Spec
04 Feb 2016   #5
pbcopter

Windows 7 Ultimate x64 SP1, Windows 8.1 Pro x64, Windows 10 Pro x64
 
 

These are the required changes to get the clock to be 12 Hr instead of 24 HR.

A .gadget file is just a compressed file (.zip). It can be opened with 7Zip and when editing is done recompressed to a zip file again. Select all the files that were extracted, including the modified SC2Clock.html file, and then recreate the zip file. Then rename the .zip file to .gadget to install.
You can edit the SC2Clock.html with Notepad.

Original Clock code in file SC2Clock.html

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

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

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

  var currentTimeString = currentHours + ":" + currentMinutes;

  document.getElementById("gadgetContent").firstChild.nodeValue = currentTimeString;
}
Modified Clock code in file SC2Clock.html
Changes/Additions to get 12HR clock are in bold type.

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

  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM"; 
 
 currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;   
  currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;
  currentHours = ( currentHours == 0 ) ? 12 : currentHours;



  var currentTimeString = currentHours + ":" + currentMinutes + " " + timeOfDay;
 
  document.getElementById("gadgetContent").firstChild.nodeValue = currentTimeString;
}
My System SpecsSystem Spec
Reply

 Gadget Help; change 24-hour clock into 12-hours




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Clock Problem - Looses an hour, but does not happen all the time.
This is not the Asus Z87 BIOS freeze clock problem. When first turned on the clock is not frozen to the time it was when the PC was shut off. When I first turn on my PC the clock is correct and once the clock looses an hour the clock still keeps the correct time, it is just the correct time minus...
General Discussion
24 hour clock keep defaulting back to am/pm setting
Hi All Sorry but I'm new to win 7 and I have a non critical issue, but it keep irritating me :cry: If I change the time to 24hour clock, outlook and the win time keep the 24hour format, but the it during the day goes back to am/pm setting, this also happens if I restarts or returns after...
General Discussion
Clock on pc lost 2 hours on the clock ?
Anyone know what could cause this? I have two towers I built that I switch back and forth on mainly to keep the antivirus up to date. This particular one when left off for a couple days lost 2 hours on the clock. This is also, the one that when I turned it on a while back it was so screwed up I had...
Performance & Maintenance
The Clock Gadget
I recently had to format my hard drive and reinstall windows. I lost a gadget that I loved. The label on it said "The Clock" But it showed the date, time, day etc. I really liked it. I do happen to have a picture of it. I was showing someone how to do screen capture through windows and used...
Gadgets
24 Hour Clock?
I would like to change the clock in the taskbar from 12 hour to 24 hour. How do I achieve this?
Customization
Clock Gadget won't change! =(
Hey all i used to have a blue clock, then i got rid of it and now i went back and its red. so I customized another one and I replaced the file trad.png with my trad.png and renamed the original to trad1.png but still the clock gadget shows the original one =( Please help me! Thanks, p.s -...
Gadgets


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 05:46.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App