laraxgram/tempora
Composer 安装命令:
composer require laraxgram/tempora
包简介
Advanced interface for working with date and time, based on Carbon.
README 文档
README
Advanced interface for working with date and time, based on Carbon. https://carbon.nesbot.com
<?php use LaraGram\Tempora\Tempora; printf("Right now is %s", Tempora::now()->toDateTimeString()); printf("Right now in Vancouver is %s", Tempora::now('America/Vancouver')); //implicit __toString() $tomorrow = Tempora::now()->addDay(); $lastWeek = Tempora::now()->subWeek(); $officialDate = Tempora::now()->toRfc2822String(); $howOldAmI = Tempora::createFromDate(1975, 5, 21)->age; $noonTodayLondonTime = Tempora::createFromTime(12, 0, 0, 'Europe/London'); $internetWillBlowUpOn = Tempora::create(2038, 01, 19, 3, 14, 7, 'GMT'); // Don't really want this to happen so mock now Tempora::setTestNow(Tempora::createFromDate(2000, 1, 1)); // comparisons are always done in UTC if (Tempora::now()->gte($internetWillBlowUpOn)) { die(); } // Phew! Return to normal behaviour Tempora::setTestNow(); if (Tempora::now()->isWeekend()) { echo 'Party!'; } // Over 200 languages (and over 500 regional variants) supported: echo Tempora::now()->subMinutes(2)->diffForHumans(); // '2 minutes ago' echo Tempora::now()->subMinutes(2)->locale('zh_CN')->diffForHumans(); // '2分钟前' echo Tempora::parse('2019-07-23 14:51')->isoFormat('LLLL'); // 'Tuesday, July 23, 2019 2:51 PM' echo Tempora::parse('2019-07-23 14:51')->locale('fr_FR')->isoFormat('LLLL'); // 'mardi 23 juillet 2019 14:51' // ... but also does 'from now', 'after' and 'before' // rolling up to seconds, minutes, hours, days, months, years $daysSinceEpoch = Tempora::createFromTimestamp(0)->diffInDays(); // something such as: // 19817.6771 $daysUntilInternetBlowUp = $internetWillBlowUpOn->diffInDays(); // Negative value since it's in the future: // -5037.4560 // Without parameter, difference is calculated from now, but doing $a->diff($b) // it will count time from $a to $b. Tempora::createFromTimestamp(0)->diffInDays($internetWillBlowUpOn); // 24855.1348
Installation
With Composer
$ composer require laraxgram/tempora
<?php require 'vendor/autoload.php'; use LaraGram\Tempora\Tempora; printf("Now: %s", Tempora::now());
Documentation
laraxgram/tempora 适用场景与选型建议
laraxgram/tempora 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 267 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 07 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「time」 「date」 「bot」 「datetime」 「carbon」 「telegram」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 laraxgram/tempora 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 laraxgram/tempora 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 laraxgram/tempora 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dialogflow php sdk
Tools to convert between .NET and PHP date formats
Adds the EDTF data type to Wikibase
Laravel 5.6 Monolog custom telegram channel
A powerful event calendar Tool for Laravel's Nova 5.
Date component is a set of methods to help with the manipulation of dates.
统计信息
- 总下载量: 267
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 26
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-10