Download the PHP package vascowhite/time without Composer

On this page you can find all versions of the php package vascowhite/time. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package time

Moved to https://gitlab.com/vascowhite/Time

Time

Build Status

Introduction

This is a class for dealing with times.

This time data type represents a period of time. It is expressed in the format 'H:i:s' (a left truncation of the representation of datetime). It is the elapsed time that would be measured on a stop watch that is unaware of date, time zones or DST.

PHP's native \DatePeriod is excellent for representing a time period of any length, however it does not lend itself to manipulating time periods or performing calculations with them. Hence, this class was born. Its scope has been limited to hours, minutes and seconds for now as this allows for accurate manipulation without worrying about DST, etc., the DateTime classes already have that well covered.

This class can add, subtract, average, sum and compare times. It will also convert a \DateInterval object to a TimeValue and a TimeValue object into a \DateInterval object.

Installation

Install using composer, add the following to composer.json:-

Other methods of installation are possible, but not supported.

Requirements

Requires PHP >= 5.5.0


TimeValue

This is an immutable class that represents a time data type. It knows nothing about dates, if you need times associated with dates, then PHP's \DateTime Classes are what you are looking for.

There are various methods available for manipulating and comparing TimeValue objects.

TimeValue objects implement the __toString() magic method, so can be echoed etc..


TimeValue::__construct()

Signature:-

Arguments

$time is a string representing a period of time. For example one hour, sixteen minutes and thirty seconds would be represented thus: '01:16:30'.

$format Optional format string, defaults to 'H:i:s'. Available formats are 'H:i:s', 'H', 'i', or 's'.

The following are examples of valid formats:-

Although the formats are specified none of the fields are limited to 2 digits. The following are also valid:-

Return Returns a TimeValue object.


TimeValue::getSeconds()

Signature

Arguments

None.

Return Returns an integer representing the number of seconds that the TimeValue spans.

Example


TimeValue::getTime()

Signature

Arguments

None.

Return

Returns a string representing the time in the format 'H:i:s'. The 'H' portion will expand to the required number of digits to represent the hour.

Example


TimeValue::add()

Signature

Arguments

The TimeValue to be added.

Return

Returns a TimeValue object set to the appropriate number of seconds.

Example


TimeValue::sub()

Signature

Arguments

The TimeValue to be subtracted.

Return

Returns a TimeValue object set to the appropriate number of seconds.

Example


TimeValue::average()

Signature

Arguments

An array of TimeValue objects.

Return

Returns a TimeValue object set to the average number of seconds of the TimeValue objects in the supplied array.

Example


TimeValue::sum()

Signature

Arguments

An array of TimeValue objects.

Return

Returns a TimeValue object set to the sum the TimeValue objects in the supplied array.

Example


TimeValue::createFromDateInterval()

Signature

Arguments

A \DateInterval object. A Boolean value. If true the returned \DateInterval object will represent a negative value. Defaults to false.

Return

Returns a TimeValue object set to the number of seconds represented by the \DateInterval object.

Example


TimeValue::toDateInterval()

Signature

Arguments

None.

Return

Returns a \DateInterval object with all fields set as if created by \DateTime::diff(). Returns false if the conversion fails.

Example


TimeValue::format()

Signature

Arguments

A string representing the desired format. Uses same formatting as \DateInterval::format()


All versions of time with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vascowhite/time contains the following files

Loading the files please wait ....