| Last Updated |   | Ratings |   | Unique User Downloads |   | Download Rankings | 
2025-05-08 (1 month ago)   |  | Not enough user ratings |  | Total: 311  |  | All time:  7,316 This week: 131  | 
 | 
| Description |   | Author  | 
This package can render the time on analog clock as an image. 
 
It takes a time string with hours and minutes and renders an image displaying the pointers on circular analog clock. 
 
There are two class variants: one that draws the clock pointers inside a circle and that renders the pointers over a base background image. 
 
The resulting image can be saved to a PNG file or outputted as the current script output. Innovation Award 
  May 2015 
Number 15 | 
Many applications need to display the current time. They usually display a text string with the time, but sometimes it is nicer to display the time as a drawing of an analog clock. 
 
This class can display the current time as an analog clock rendered as an image that can be displayed on the browser. 
 
Manuel Lemos | 
 
 
 
 |  | 
  | 
 | 
Innovation award
   Nominee: 2x |  
 
 
  | 
Example
<?php 
 
require_once './vendor/autoload.php'; 
 
try { 
    $clock = new PTX\ClockCanvas(); 
    $clock->draw(); 
    $file_path = './cache/base.png'; 
    $clock->to_file($file_path); 
    $clock->to_browser(); 
} catch(\PTX\ClockException $e) { 
    echo $e->getMessage(); 
} 
 
 | 
 
Details
PTX-Clock
PHP Class to create analog clock from the time given. I have a son and they are teaching him at school the clock.
I though it would be great to create a simple game to help him out. This class is just a beginning of the whole idea.
Installation
You will need a composer to install autoload for you
composer install --no-dev
Example
require_once './vendor/autoload.php';
try {
    $clock = new PTX\Clock('09:55');
    $clock->draw();
    $clock->to_browser();
} catch(\PTX\ClockException $e) {
    echo $e->getMessage();
}
Example online
Visit my page and see it in action.
 
 
|   | 
Applications that use this package | 
  | 
No pages of applications that use this class were specified.
 If you know an application of this package, send a message to the author to add a link here.