PHP code example of zjkal / time-helper

1. Go to this page and download the library: Download zjkal/time-helper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zjkal / time-helper example snippets



//判断指定日期是否为国内的工作日
ChinaHoliday::isWorkday('2023-01-23');

//判断指定日期是否为国内的节假日
ChinaHoliday::isHoliday(1646360133);

//返回友好的时间格式,如:刚刚,N秒前,N分钟前,N小时前等等
TimeHelper::toFriendly('2022-3-2 10:15:33');
//返回友好的时间格式(英文)
TimeHelper::toFriendly(1646186290, 'en');

//判断日期是否为今天
TimeHelper::isToday('2020-4-10 23:01:11');

//判断日期是否为工作日(周一到周五)
TimeHelper::isWeekday('2023-03-08');

//计算两个日期相差天数
TimeHelper::diffDays('2022-4-10 23:01:11','Apr 11, 2020');

//返回15天前0点的时间戳
TimeHelper::beforeDay(15,null,true);

//返回15天后的时间戳
TimeHelper::afterDay(15);

//返回5个月后的时间戳
TimeHelper::afterMonth(5);

//将任意格式的时间转换为指定格式
TimeHelper::format('Y-m-d H:i:s','May 3, 2022');

//将任意时间类型的字符串转为时间戳
TimeHelper::toTimestamp('Apr 11, 2020');

//获取当前时间
TimeHelper::now();