定制 namnv609/timezonedb-php-api 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

namnv609/timezonedb-php-api

Composer 安装命令:

composer require namnv609/timezonedb-php-api

包简介

PHP API client for TimeZoneDB.com

README 文档

README

TimeZoneDB provides free time zone database for cities of the world. The database is licensed under Creative Commons Attribution 3.0 License. It contains countries name, time zones, abbreviation, GMT offset, and Daylight Saving Time (DST). The data is available in CSV and SQL format. You can download and implement into your projects for free.

System requirements

  • PHP >= 5.5

Installation

Using Composer

  • composer install namnv609/timezonedb-php-api

or you can include the following in your composer.json

  • "namnv609/timezonedb-php-api": "1.0"

Usage Instructions

First, create new TimeZoneDB instance to make configuring the library for usage.

use NNV\TimeZoneDB;

$tzDB = new TimeZoneDB(<TimeZoneDB API Key>);

Once the TimeZoneDB instance has been registered. You may use it like so:

List Time Zone

List out all available time zones supported by TimeZoneDB.

$listTimeZoneParams = [
    "fields" => "countryCode,countryName",
    "country" => "NZ",
    // Other params
];
$tzDB->listTimeZone($listTimeZoneParams);

Get Time Zone

Get local time of a city by its name, time zone, latitude & longtiude, or IP address.

$getTimeZoneParams = [
    "by" => "zone",
    "zone" => "America/Chicago",
    // Other params
];
$tzDB->getTimeZone($getTimeZoneParams);

Convert Time Zone

Convert timestamp between two different time zone.

$convertTimeZoneParams = [
    "from" => "America/Los_Angeles",
    "to" => "Australia/Sydney",
    "time" => "06/01/2016 03:00PM", // You can use standard DateTime format or Unix time
    // Other params
];
$tzDB->convertTimeZone($convertTimeZoneParams);

Utilities

We support some utilities function for your usage like:

listTimeZones

List of time zones supported by TimeZoneDB

$tzDB->listTimeZones();

codeToZones

Convert country code to time zones

$tzDB->codeToZones("AQ");

// Result
[
    8 => "Antarctica/Casey",
    9 => "Antarctica/Davis",
    10 => "Antarctica/DumontDUrville",
    11 => "Antarctica/Mawson",
    12 => "Antarctica/McMurdo",
    13 => "Antarctica/Palmer",
    14 => "Antarctica/Rothera",
    15 => "Antarctica/Syowa",
    16 => "Antarctica/Troll",
    17 => "Antarctica/Vostok",
]

countryToZones

Country name to time zones

$tzDB->countryToZones("Vietnam");

// Result
[
    418 => "Asia/Ho_Chi_Minh",
]

zoneToCode

Time zone to country code

$tzDB->zoneToCode("Asia/Ho_Chi_Minh");

// Result
"VN"

zoneToCountry

Time zone to country name

$tzDB->zoneToCountry("Asia/Ho_Chi_Minh");

// Result
"Vietnam"

统计信息

  • 总下载量: 9.53k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-06-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固