ramazancetinkaya / seconds-converter
A PHP library to convert seconds into minutes, hours, and days.
Requires
- php: >=8.0
README
Seconds Converter is a PHP library designed to simplify the conversion of seconds into various time units such as minutes, hours, and days. It provides a convenient and easy-to-use interface for developers to integrate time conversion functionality into their projects.
Table of Contents
Installation
Composer
You can install the library via Composer, a dependency manager for PHP. Make sure you have Composer installed on your system. If not, you can follow the official installation guide.
-
Open your terminal or command prompt.
-
Navigate to your project directory.
-
Run the following command to add
Seconds Converter
to your project's dependencies:composer require ramazancetinkaya/seconds-converter
Composer will download and install the library and its dependencies into your project's vendor directory.
Manual Installation
If you prefer not to use Composer, you can manually include the library in your project:
- Download: Download the latest release from the GitHub releases page.
- Extract: Extract the downloaded ZIP file.
- Copy Files: Copy the contents of the
src
directory into your project's desired location.
Usage
<?php require_once 'vendor/autoload.php'; // If installed via Composer use ramazancetinkaya\SecondsConverter; // Create an instance of the converter $converter = new SecondsConverter(); try { echo $converter->convert(123456); // Output: "1 days, 10 hours, 17 minutes, 36 seconds" } catch (InvalidArgumentException $e) { echo "Error: " . $e->getMessage(); } ?>
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or create a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright
© 2024 Ramazan Çetinkaya. All rights reserved.