Mũi tên ngày giờ

Định dạng và dịch chuyển thời gian thân thiện với con người.

Thử trong Trình chỉnh sửa

Tổng quan

Cung cấp một trình bao bọc thông minh để phân tích cú pháp ngày tháng python tiêu chuẩn.

Cho phép dịch chuyển đơn giản và nhiều định dạng chuỗi mà con người có thể đọc được.

Đầu ra mã & thực thi

Phân tích các chuỗi phức tạp và ngoại suy các biến thể UTC gốc.

import arrow

# Current UTC time
now = arrow.utcnow()
print(f"Now (UTC): {now.format('YYYY-MM-DD HH:mm:ss')}")

# Shift time forward
future = now.shift(days=14, hours=6)
print(f"Release date: {future.humanize()}")
print(f"Exact date:   {future.format('dddd, MMMM Do YYYY')}")

# Parse chaotic string
parsed = arrow.get("2025-07-04T12:00:00-04:00")
print(f"\nParsed US/Eastern: {parsed}")

# Convert across timezones
import pytz
zones = ['Asia/Tokyo', 'Europe/London', 'America/New_York']
print("\nFuture Date around the world:")
for tz_name in zones:
    tz = pytz.timezone(tz_name)
    local_dt = future.datetime.astimezone(tz)
    print(f"  {tz_name:<25} {local_dt.strftime('%Y-%m-%d %H:%M %Z')}")
Đầu ra thiết bị đầu cuối
Now (UTC): 2025-XX-XX XX:XX:XX
Release date: in 14 days
Exact date:   ...

Triển khai từng bước

  • Chuyển đổi múi giờ
  • Đánh giá nhật ký CRON
  • Đột biến dấu thời gian cơ sở dữ liệu

Câu hỏi thường gặp

Chủ đề liên quan