2017 © Pedro Peláez
 

library timezonedb-php-api

PHP API client for TimeZoneDB.com

image

namnv609/timezonedb-php-api

PHP API client for TimeZoneDB.com

  • Friday, June 23, 2017
  • by namnv609
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,137 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 18850 % Grown

The README.md

TimeZoneDB API

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., (*1)

System requirements

  • PHP >= 5.5

Installation

Using Composer * composer install namnv609/timezonedb-php-api, (*2)

or you can include the following in your composer.json * "namnv609/timezonedb-php-api": "1.0", (*3)

Usage Instructions

First, create new TimeZoneDB instance to make configuring the library for usage., (*4)

use NNV\TimeZoneDB;

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

Once the TimeZoneDB instance has been registered. You may use it like so:, (*5)

List Time Zone

List out all available time zones supported by TimeZoneDB., (*6)

$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., (*7)

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

Convert Time Zone

Convert timestamp between two different time zone., (*8)

$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:, (*9)

listTimeZones

List of time zones supported by TimeZoneDB, (*10)

$tzDB->listTimeZones();

codeToZones

Convert country code to time zones, (*11)

$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, (*12)

$tzDB->countryToZones("Vietnam");

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

zoneToCode

Time zone to country code, (*13)

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

// Result
"VN"

zoneToCountry

Time zone to country name, (*14)

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

// Result
"Vietnam"

The Versions

23/06 2017

dev-master

9999999-dev

PHP API client for TimeZoneDB.com

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar namnv609

restful api time zone timezonedb.com convert time zone

23/06 2017

v1.0

1.0.0.0

PHP API client for TimeZoneDB.com

  Sources   Download

MIT

The Requires

 

by Avatar namnv609

restful api time zone timezonedb.com convert time zone