hilalahmad/date-time 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hilalahmad/date-time

Composer 安装命令:

composer require hilalahmad/date-time

包简介

Creating a PHP package for date and time manipulation can be highly useful, especially when dealing with various date-related functionalities. Let's call this package DateTime.

README 文档

README

Creating a PHP package for date and time manipulation can be highly useful, especially when dealing with various date-related functionalities. Let's call this package "DateTime."

GitHub issues GitHub stars Total Downloads License

20+ function you can use it in your project make your project with better data and time.

Installation

You can install this package using Composer, a popular PHP package manager:

composer require hilalahmad/date-time

Basic Usage

Here's an example of how to use the date and time package:

use Hilalahmad\DateAndTime\DateAndTime;
  

// Format the current date
$formattedDate = DateAndTime::formatDate('Y-m-d H:i:s', '2020234');
echo "Formatted Date: $formattedDate\n";

// Calculate the difference between two dates
$date1 = '2022-01-01 00:00:00';
$date2 = '2022-01-29 00:00:00';
$daysDifference = DateAndTime::dateDifference($date1, $date2, 'days');
echo "Days Difference: $daysDifference\n";

// Parse a date string
$dateString = '2022-12-31 23:59:59';
$parsedDate = DateAndTime::parseDate($dateString);
echo "Parsed Date: " . $parsedDate->format('Y-m-d H:i:s') . "\n";

// Get the current timestamp
$currentTimestamp = DateAndTime::getCurrentTimestamp();
echo "Current Timestamp: $currentTimestamp\n";

$futureDate = '2023-12-31 12:00:00';
$pastDate = '2020-01-01 00:00:00';

$futureCheck = DateAndTime::isInFuture($futureDate);
$pastCheck = DateAndTime::isInPast($pastDate);

echo "Is $futureDate in the future? " . ($futureCheck ? 'Yes' : 'No') . "\n";
echo "Is $pastDate in the past? " . ($pastCheck ? 'Yes' : 'No') . "\n";

$newDate = DateAndTime::addYears('2022-01-01 00:00:00', 5);
echo "Date after adding 5 years: $newDate\n";

$previousMonth = DateAndTime::subtractMonths('2022-08-15 12:00:00', 1);
echo "Date after subtracting 1 month: $previousMonth\n";

$dayOfWeek = DateAndTime::getDayOfWeek('2022-11-20 00:00:00');
echo "Day of the week: $dayOfWeek\n";


$age = DateAndTime::calculateAge('1990-05-15');
echo "Age: $age\n";

$overlap = DateAndTime::doDateRangesOverlap('2022-01-01', '2022-01-10', '2022-01-05', '2022-01-15');
echo "Do date ranges overlap? " . ($overlap ? 'Yes' : 'No') . "\n";

$timestamp = strtotime('2023-11-16 16:34:56');
$relativeTime = DateAndTime::relativeTime($timestamp);
echo "Relative Time: $relativeTime\n";

$weekNumber = DateAndTime::getCurrentWeekNumber();
echo "Current Week Number: $weekNumber\n";

$isCurrentMonth = DateAndTime::isCurrentMonth(2022, 11);
echo "Is November 2022 the current month? " . ($isCurrentMonth ? 'Yes' : 'No') . "\n";

$isWeekend = DateAndTime::isWeekend('2022-11-20');
echo "Is November 20, 2022, a weekend? " . ($isWeekend ? 'Yes' : 'No') . "\n";

$quarter = DateAndTime::getQuarter('2022-11-15');
echo "Quarter of November 15, 2022: $quarter\n";

$isFutureYear = DateAndTime::isFutureYear(2023);
echo "Is 2023 a future year? " . ($isFutureYear ? 'Yes' : 'No') . "\n";

$isToday = DateAndTime::isToday('2022-11-15');
echo "Is today November 15, 2022? " . ($isToday ? 'Yes' : 'No') . "\n";

$nextWeekdays = DateAndTime::getNextWeekdays('2022-11-15', 5);
echo "Next 5 weekdays from November 15, 2022: " . implode(', ', $nextWeekdays) . "\n";

$lastDayOfMonth = DateAndTime::getLastDayOfCurrentMonth();
echo "Last day of the current month: $lastDayOfMonth\n";

$isMorning = DateAndTime::isInMorning('2022-11-15 08:30:00');
echo "Is 8:30 AM on November 15, 2022, in the morning? " . ($isMorning ? 'Yes' : 'No') . "\n";

$nextMonths = DateAndTime::getNextMonths('2022-11-15', 3);
echo "Next 3 months from November 15, 2022: " . implode(', ', $nextMonths) . "\n";

$daysDifference = DateAndTime::getDaysDifference('2022-01-01', '2023-01-01');
echo "Days Difference: $daysDifference\n";

$leapYearCheck = DateAndTime::isLeapYear(2024);
echo "Is 2024 a leap year? " . ($leapYearCheck ? 'Yes' : 'No') . "\n";

$monthRange = DateAndTime::getMonthRange(2022, 8);
echo "August 2022 Range: {$monthRange['first_day']} to {$monthRange['last_day']}\n";

Contribution

If you'd like to contribute to this package or report issues, please check the Github repo for more details.

License

This package is open-source and is licensed under the MIT License.

hilalahmad/date-time 适用场景与选型建议

hilalahmad/date-time 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 11 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「data-time」 「dateandtime」 「datetimeformat」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 hilalahmad/date-time 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 hilalahmad/date-time 我们能提供哪些服务?
定制开发 / 二次开发

基于 hilalahmad/date-time 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-20