Our Unix Timestamp Conversion Tool provides a series of API interfaces to help developers integrate timestamp conversion functionality into their applications.
Endpoint: /api/timestamp-to-datetime
Method: GET
Parameters:
timestamp - Unix timestamp (required)timezone - Timezone (optional, defaults to
user's local timezone)Response Format: JSON
Response Example:
{
"timestamp": 1609459200,
"datetime": "2021-01-01 08:00:00",
"timezone": "Asia/Shanghai"
}
Endpoint: /api/datetime-to-timestamp
Method: GET
Parameters:
datetime - Date-Time (required, format:
YYYY-MM-DD HH:MM:SS)Response Format: JSON
Response Example:
{
"datetime": "2021-01-01 08:00:00",
"timestamp": 1609459200
}
Endpoint: /api/current-timestamp
Method: GET
Parameters: None
Response Format: JSON
Response Example:
{
"timestamp": 1609459200,
"datetime": "2021-01-01 08:00:00"
}
Here are some examples of using the API interfaces:
// 时间戳转日期时间
fetch('/api/timestamp-to-datetime?timestamp=1609459200')
.then(response => response.json())
.then(data => console.log(data));
// 日期时间转时间戳
fetch('/api/datetime-to-timestamp?datetime=2021-01-01 08:00:00')
.then(response => response.json())
.then(data => console.log(data));
// 获取当前时间戳
fetch('/api/current-timestamp')
.then(response => response.json())
.then(data => console.log(data));
import requests
# 时间戳转日期时间
response = requests.get('http://unixtimestamp.le-ai.top/api/timestamp-to-datetime', params={'timestamp': 1609459200})
print(response.json())
# 日期时间转时间戳
response = requests.get('http://unixtimestamp.le-ai.top/api/datetime-to-timestamp', params={'datetime': '2021-01-01 08:00:00'})
print(response.json())
# 获取当前时间戳
response = requests.get('http://unixtimestamp.le-ai.top/api/current-timestamp')
print(response.json())