Skip to main content
DevTools24

日期差异计算器

计算两个日期之间的精确差异,以天、周和月为单位。包括工作日计数。

Date Calculations - 技术详情

Date difference calculations account for varying month lengths and leap years. Working days exclude Saturdays and Sundays from the count.

命令行替代方案

# Using GNU date
echo $(( ( $(date -d '2024-12-31' +%s) - $(date -d '2024-01-01' +%s) ) / 86400 )) days

# Using Python
python3 -c "from datetime import date; print((date(2024,12,31) - date(2024,1,1)).days)"