1. Go to this page and download the library: Download yue/yeararound 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/ */
yue / yeararound example snippets
use Yue\YearAround\Context;
use Yue\YearAround\Contracts\ISeason;
use Yue\YearAround\Contracts\IMonth;
use Yue\YearAround\Utilities\DateParser;
$year = Context::CreateYear(2018);
// Check if the leap year
$isLeapYear = $year->isLeapYear(); // false 是否为闰年
$seasons = $year->getSeasons();
foreach($seasons as $season){
/** @var ISeason $season */
var_dump($season->getName());
// Get months of each season, it will be adjusted by hemisphere setting in .env
// 获取每个季度或者季节包含的月份 会根据 .env 文件中半球的设置自动生成
$months = $season->getMonths();
foreach($months as $month){
/** @var IMonth $month */
var_dump($month);
}
}
// Can get the end day of any month in any year
// 可以获取某个月在任何年的最后一天
$feb = DateParser::GetMonth(2);
$lastDayInt = $feb->getLastDay(2000)->day; // It's 29 得到闰月值 29
$lastDayInt = $feb->getLastDay(2001)->day; // It's 28 得到闰月值 28
use Yue\YearAround\Context;
use Yue\YearAround\Contracts\IConstellation;
use Yue\YearAround\Utilities\DateParser;
use Yue\YearAround\Utilities\DictionaryFactory;
$constellation = Context::CreateConstellation(1,11,DictionaryFactory::GetInstance('en'));
var_dump($constellation->getName()); // Capricorn 摩羯座
var_dump($constellation->getFistDay()->format('d/M')); // 22/Dec 从12月22日
var_dump($constellation->getLastDay()->format('d/M')); // 19/Jan 至1月19日
// Get previous and next 获取前一个星座和下一个星座的名称
var_dump($constellation->prev()->getName()); // Sagittarius 前一个星座是射手座
var_dump($constellation->next()->getName()); // Aquarius 下一个星座是水瓶座
// Get constellation by give tpye 获取指定的星座
$leo = Context::CreateConstellation(null, null, null, IConstellation::Leo);
var_dump($leo->getName()); // Leo 狮子座