The Time Unit Converter API allows you to convert time values between different units (seconds, minutes, hours, days, and weeks) with optional multipliers. This is useful for time calculations, scheduling, and unit standardization.
Conversion Rates (to seconds):
Seconds: 1 (base unit)
Minutes: 60 seconds
Hours: 3,600 seconds
Days: 86,400 seconds
Weeks: 604,800 seconds
Key Features
RESTful design with JSON input/output
CORS enabled for cross-origin requests
Support for all common time units
Optional multiplier for scaling values
Single request returns all unit conversions
Results rounded to 1 decimal place
Self-documenting API with info endpoint
Getting Started
Base URL
https://www.promptbox.cn/api/time.php
Authentication
This API does not require authentication. All endpoints are publicly accessible.
Content Type
All requests and responses use JSON format. Include the following header in your requests:
Content-Type: application/json
Rate Limiting
Currently, there are no rate limits imposed on this API. However, please use it responsibly.
API Endpoints
POST
Convert Time Units
POST /time.php?action=convert
Description
Converts a time value from one unit to all other supported units. Optionally applies a multiplier to scale the input value.
Request Body
Parameter
Type
Required
Description
value
number
Required
The time value to convert
fromUnit
string
Required
Source unit: "seconds", "minutes", "hours", "days", or "weeks"
multiplier
number
Optional
Multiplier to apply to the value (default: 1, must be > 0)
import requests
import json
def convert_time(value, from_unit, multiplier=1):
"""Convert time units using the API"""
url = "https://www.promptbox.cn/api/time.php?action=convert"
payload = {
"value": value,
"fromUnit": from_unit,
"multiplier": multiplier
}
try:
response = requests.post(url, json=payload, timeout=10)
response.raise_for_status()
result = response.json()
if result.get('success'):
print(f"Conversions: {result['data']['conversions']}")
return result['data']
else:
print(f"API Error: {result.get('error')}")
returnNoneexcept requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
returnNone# Usage examples
convert_time(30, 'minutes')
convert_time(2, 'hours', 1.5)
convert_time(1, 'weeks')
Conversion Reference
Quick Reference Table
From
To Seconds
To Minutes
To Hours
To Days
To Weeks
1 Second
1
0.017
0.0003
0.00001
0
1 Minute
60
1
0.017
0.0007
0.0001
1 Hour
3,600
60
1
0.042
0.006
1 Day
86,400
1,440
24
1
0.143
1 Week
604,800
10,080
168
7
1
Common Conversions
90 minutes = 1.5 hours = 5,400 seconds
48 hours = 2 days = 2,880 minutes
72 hours = 3 days = 0.43 weeks
1,440 minutes = 24 hours = 1 day
10,080 minutes = 168 hours = 7 days = 1 week
Changelog
Version 1.0.0 (Current)
Initial release
POST /time.php?action=convert endpoint
GET /time.php?action=info endpoint
Support for seconds, minutes, hours, days, and weeks
Optional multiplier functionality
JSON request/response format
CORS support
Comprehensive error handling
Results rounded to 1 decimal place
FAQ
Q: What happens if I don't provide a multiplier?
A: The multiplier defaults to 1, meaning the value is converted as-is without any scaling.
Q: Can I use decimal values?
A: Yes! Both the value and multiplier accept decimal numbers (e.g., 2.5 hours, 1.5x multiplier).
Q: Why are some results showing 0?
A: Very small values may round to 0 when converted to larger units. For example, 1 second = 0.0 weeks. Check the valueInSeconds field for the precise intermediate value.
Q: What precision is used for calculations?
A: All calculations are performed with full floating-point precision, but results are rounded to 1 decimal place in the response.
Q: Do I need authentication?
A: No, the API is currently open and does not require authentication.
Q: Is the fromUnit parameter case-sensitive?
A: No, unit names are case-insensitive. "Minutes", "minutes", and "MINUTES" all work.
Q: Can I convert between specific units only?
A: The API always returns conversions for all supported units. Simply extract the specific unit you need from the conversions object.
Q: What's the maximum value I can convert?
A: There's no enforced maximum, but be aware of floating-point precision limits for extremely large numbers.
Q: Is CORS enabled?
A: Yes, the API has CORS enabled and can be called from any domain.
Q: How do I report bugs or request features?
A: Contact the API administrator or submit issues through your preferred channel.
Support & Contact
If you need assistance with the API or have questions not covered in this documentation:
Documentation Issues
If you find errors or unclear sections in this documentation, please report them.
Technical Support
For technical issues or integration help, contact your API administrator.
Feature Requests
Have an idea for improving the API? We'd love to hear your suggestions!