Download the PHP package zjkal/time-helper without Composer

On this page you can find all versions of the php package zjkal/time-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?
zjkal/time-helper
Rate from 1 - 5
Rated 5.00 based on 3 reviews

Informations about the package time-helper


TimeHelper

中文 | English

License PHP Version Require Latest Stable Version Total Downloads GitHub Workflow Status

TimeHelper 是一个简单易用的PHP时间日期助手类库,可以快速实现常用的时间日期操作,比如获取指定时间的秒数,获取友好的时间格式,判断时间范围,计算两个时间相差值,返回N小时/天/星期/月/年前或者后的时间戳等等

🧩特性

🚀安装

通过Composer导入类库

🌈使用文档

查看使用文档或阅读以下简要说明

1. 获取需要的秒数

一般用于设置缓存时间,设置结束时间等

2. 返回友好的日期格式,比如N秒前,N分钟前,N小时前等等

一般用于社交类平台,评论,论坛等

3. 判断时间范围

4. 计算两个时间相差值

如果只传入一个参数,则与当前时间比较

5. 返回N小时/天/星期/月/年前或者后的时间戳

只传入1个参数以当前时间计算,传入第2个参数则以该时间计算,传入第3个参数为true,则时间取整

6.获取当前秒级/毫秒级/微秒级/纳秒级的时间戳

生成订单号或者与其他编程语言对接时可能会用到

7.日期转换

用于爬虫爬取网页或第三方程序对接时,时间格式不统一的转换

8.平闰年相关

比原生方法使用起来更方便

9.时区相关 🆕

主要提供获取不同时区的时间和转换不同时区的时间的方法

所支持的时区列表请参考时区列表

10.国内节假日/工作日相关 🔥

专门针对国内的节假日进行判断,目前包含2020年-2024年的节假日数据,后续也会持续更新. 为了便于维护,另起了一个类ChinaHoliday,同样可以传入任意类型的时间格式或时间戳

特别说明: 所有时间的方法都可以传入任意格式的时间或者时间戳, 但是有一点请注意 m/d/y 或 d-m-y 格式的日期,如果分隔符是斜线(/),则使用美洲的 m/d/y 格式。如果分隔符是横杠(-)或者点(.),则使用欧洲的 d-m-y 格式。为了避免潜在的错误,您应该尽可能使用 YYYY-MM-DD 格式或其他格式.

📃更新日志

v1.1.8 2024年6月6日

  • 修复了获取友好时间的错误

v1.1.7 2024年6月1日

  • 增加了计算两个日期相差秒数的方法diffSeconds()
  • 增加了计算两个日期相差分钟数的方法diffMinutes()
  • 增加了计算两个日期相差小时数的方法diffHours()
  • 增加了根据日期字符串, 修改指定时间的方法modifyTimestamp()
  • 精简代码

v1.1.6 2024年4月25日

  • 增加了判断是否为昨天的方法isYesterday()
  • 增加了判断是否为明天的方法isTomorrow()
点击查看更多 > v1.1.5 2024年2月5日 > * 精简和优化代码 > v1.1.4 2023年10月25日 > * 增加了2024年国内节假日的数据 > v1.1.3 2023年10月19日 > * 提升了toTimestamp()方法的兼容性,可以转换一些特殊格式的时间了 > v1.1.2 2023年9月16日 > * 增加了比较两个时间早晚的方法compare() > v1.1.1 2023年8月15日 > * 增加了时区相关的方法,可以将任意格式的时间或时间戳转换为指定时区的时间 > v1.1.0 2023年3月19日 > * 增加了ChinaHoliday类,专门用于维护国内节假日相关的方法 > * 增加了判断是否为国内工作日的方法isWorkday() > * 增加了判断是否为国内节假日的方法isHoliday() > v1.0.10 2023年3月13日 > * 增加判断指定日期是否为平常日的方法isWeekday() > * 增加判断指定日期是否为周末的方法isWeekend() > v1.0.9 2023年3月8日 > * 修改toTimestamp()方法不传参数或传入空参数时,不再抛出异常,而是返回当前时间戳 > * 增加了判断是否是闰年的方法isLeapYear() > * 增加了获取该日期当年的天数的方法daysInYear() > * 增加了获取该日期当月的天数的方法daysInMonth() > v1.0.8 2023年2月21日 > * 增加了判断指定时间是星期几的方法getWeekDay() > v1.0.7 2023年2月8日 > * 增加了将任意格式的时间转换为指定格式的方法format() > * 删除废弃方法friendly_date(),请使用toFriendly()代替 > v1.0.6 2023年1月27日 > * 修复BUG > v1.0.5 2023年1月16日 > * 优化了友好的时间显示算法 > v1.0.4 2023年1月8日 > * 修复了变量类型的BUG > v1.0.3 2023年1月7日 > * 增加了判断一个字符串是否为时间戳的方法 > * 增加了将任意时间类型的字符串转为时间戳的方法 > * 增加了获取秒级/毫秒级/微秒级/纳秒级的时间戳的方法 > v1.0.2 2023年1月5日 > * 增加了返回N分钟/小时的秒数的方法 > v1.0.1 2023年1月4日 > * 返回N分钟/小时/天/月/年前或后的时间戳所有方法,增加了是否取整的参数. > v1.0.0 2022年8月25日 > * 从tp-helper的时间类中独立出来

❤️由 JetBrains 赞助

非常感谢 Jetbrains 为我提供的 IDE 开源许可,让我完成此项目和其他开源项目上的开发工作。

😎开发者们

🐧扫以下二维码加入QQ频道

📖开源协议

TimeHelper遵循MIT开源协议, 意味着您无需任何授权, 即可免费将TimeHelper应用到您的项目中


All versions of time-helper with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zjkal/time-helper contains the following files

Loading the files please wait ....