duiliopastorelli/get-month

一个简单的类,用于以不同格式和语言获取月份。

1.0.8 2016-05-29 16:33 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:20:05 UTC


README

一个简单的类,用于以不同格式和语言获取月份。

通过 Composer 安装

$ composer require duiliopastorelli/get-Month

使用 Composer 的用法

你可以用以下方式调用类:

<?php
require "vendor/autoload.php";

use DuilioPastorelli\Month;

echo Month::getMonth();

或者,如果你不想在最上面添加 "use DuilioPastorelli\Month",你可以

<?php
require "vendor/autoload.php";

echo \DuilioPastorelli\Month::getMonth();

查看 用法 部分,了解更多选项。

##安装 "快速而简单" 将 "Month.php" 文件复制到你的项目内部。

包含它

<?php
include "[PATH]/month.php";

echo Month::getMonth();

查看 用法 部分,了解更多选项。

##用法

###获取以数字格式(1-12)表示的月份

Month::getMonth();

###获取特定语言的当前月份翻译

Month::getMonth("[LANGUAGE]");

支持的语言包括

  1. 意大利语 -> it
  2. 德语 -> de

###获取上一个月和下一个月(时间机器)的数字格式

Month::getMonth(null, 1);
Month::getMonth(null, -1);

时间机器支持 1-11 和 -1--11 的值

###获取特定月份(3表示三月)的数字格式

Month::getMonth(null, null, 3);

##其他示例

  • 获取下一个月的德语翻译
Month::getMonth("de", 1);
  • 获取特定的德语月份(四月)
Month::getMonth("de", null, 4);