PHP code example of shayvmo / shayvmo-utils
1. Go to this page and download the library: Download shayvmo/shayvmo-utils 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/ */
shayvmo / shayvmo-utils example snippets
// 返回DateTime
DateUtil::date(); // 返回当前时间
DateUtil::date(time()); // 也可以指定时间戳
// 一天开始和结束时间
DateUtil::beginOfDay(time());// 2024-05-24 00:00:00
DateUtil::endOfDay(time());// 2024-05-24 23:59:59
// 一年后
DateUtil::offset("2024-05-24 10:00:00", DateField::YEAR, 1);
// 一天后
DateUtil::offsetDay("2024-05-24 10:00:00", 1);
//昨天
DateUtil.yesterday();
//明天
DateUtil.tomorrow();
//上周
DateUtil.lastWeek();
//下周
DateUtil.nextWeek();
//上个月
DateUtil.lastMonth();
//下个月
DateUtil.nextMonth();