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

SylkRode

New member
Local time
10:15 PM
Messages
9

My Computer My Computer

At a glance

Windows 7 Home Premium 64-bit
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Hewlett-Packard
OS
Windows 7 Home Premium 64-bit

My Computer My Computer

At a glance

Windows 10 Pro x64, Windows 8.1 Pro x64, Wind...INTEL i9-7920X LGA 206664 GB (4 X 16 GB) G-Skill V Series DDR4 3200 ...EVGA GTX 1060 SC 3 GB
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built
OS
Windows 10 Pro x64, Windows 8.1 Pro x64, Windows 7 Ultimate x64 SP1,
CPU
INTEL i9-7920X LGA 2066
Motherboard
Gigabyte X299-WU8 F3
Memory
64 GB (4 X 16 GB) G-Skill V Series DDR4 3200 Quad Channel
Graphics Card(s)
EVGA GTX 1060 SC 3 GB
Sound Card
Realtek Onboard ALC1220
Monitor(s) Displays
2 x Samsung S27E310
Screen Resolution
1920x1080
Hard Drives
Samsung 2 x 970 EVO Plus 500 GB NVMe
1 x 6TB WD 6003FZBX SATA
1 x 6TB WD 60EFRX SATA
12 x 3TB WD 30EFRX SATA
PSU
Seasonic X-1050
Case
Thermaltake Armor+
Cooling
Corsair H80i V2 Liquid AOI Cooler
Keyboard
Logitech G510s
Mouse
Logitech MX Master 2S
Internet Speed
200 Mb/s
Antivirus
ESET NOD32 13.1
Browser
EDGE (Dev, Canary, Beta), Chrome
Other Info
ASUS RT-AC68U router
Malwarebytes 4.0.4
Point is, I quite like the look of that clock.
 

My Computer My Computer

At a glance

Windows 7 Home Premium 64-bit
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Hewlett-Packard
OS
Windows 7 Home Premium 64-bit
See the next post.
 

Attachments

  • clk.PNG
    clk.PNG
    28.3 KB · Views: 6
Last edited:

My Computer My Computer

At a glance

Windows 10 Pro x64, Windows 8.1 Pro x64, Wind...INTEL i9-7920X LGA 206664 GB (4 X 16 GB) G-Skill V Series DDR4 3200 ...EVGA GTX 1060 SC 3 GB
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built
OS
Windows 10 Pro x64, Windows 8.1 Pro x64, Windows 7 Ultimate x64 SP1,
CPU
INTEL i9-7920X LGA 2066
Motherboard
Gigabyte X299-WU8 F3
Memory
64 GB (4 X 16 GB) G-Skill V Series DDR4 3200 Quad Channel
Graphics Card(s)
EVGA GTX 1060 SC 3 GB
Sound Card
Realtek Onboard ALC1220
Monitor(s) Displays
2 x Samsung S27E310
Screen Resolution
1920x1080
Hard Drives
Samsung 2 x 970 EVO Plus 500 GB NVMe
1 x 6TB WD 6003FZBX SATA
1 x 6TB WD 60EFRX SATA
12 x 3TB WD 30EFRX SATA
PSU
Seasonic X-1050
Case
Thermaltake Armor+
Cooling
Corsair H80i V2 Liquid AOI Cooler
Keyboard
Logitech G510s
Mouse
Logitech MX Master 2S
Internet Speed
200 Mb/s
Antivirus
ESET NOD32 13.1
Browser
EDGE (Dev, Canary, Beta), Chrome
Other Info
ASUS RT-AC68U router
Malwarebytes 4.0.4
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 ( );
  [B]var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";[/B] 
 
 currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;   
  [B]currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;
  currentHours = ( currentHours == 0 ) ? 12 : currentHours;[/B]



  var currentTimeString = currentHours + ":" + currentMinutes[B] + " " + timeOfDay[/B];
 
  document.getElementById("gadgetContent").firstChild.nodeValue = currentTimeString;
}
 

My Computer My Computer

At a glance

Windows 10 Pro x64, Windows 8.1 Pro x64, Wind...INTEL i9-7920X LGA 206664 GB (4 X 16 GB) G-Skill V Series DDR4 3200 ...EVGA GTX 1060 SC 3 GB
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built
OS
Windows 10 Pro x64, Windows 8.1 Pro x64, Windows 7 Ultimate x64 SP1,
CPU
INTEL i9-7920X LGA 2066
Motherboard
Gigabyte X299-WU8 F3
Memory
64 GB (4 X 16 GB) G-Skill V Series DDR4 3200 Quad Channel
Graphics Card(s)
EVGA GTX 1060 SC 3 GB
Sound Card
Realtek Onboard ALC1220
Monitor(s) Displays
2 x Samsung S27E310
Screen Resolution
1920x1080
Hard Drives
Samsung 2 x 970 EVO Plus 500 GB NVMe
1 x 6TB WD 6003FZBX SATA
1 x 6TB WD 60EFRX SATA
12 x 3TB WD 30EFRX SATA
PSU
Seasonic X-1050
Case
Thermaltake Armor+
Cooling
Corsair H80i V2 Liquid AOI Cooler
Keyboard
Logitech G510s
Mouse
Logitech MX Master 2S
Internet Speed
200 Mb/s
Antivirus
ESET NOD32 13.1
Browser
EDGE (Dev, Canary, Beta), Chrome
Other Info
ASUS RT-AC68U router
Malwarebytes 4.0.4
Back
Top