Download the PHP package neunerlei/tiny-timy without Composer

On this page you can find all versions of the php package neunerlei/tiny-timy. 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 tiny-timy

Tiny Timy - DateTimy

There are a lot of really powerful date and time libraries out there (carbon, chronos, ...) that are valid if you have to do a lot of date-related actions. For the most part of my daily work I just need date formatting and correct timezone handling. Using huge classes with thousands of lines of code for formatting a date time object always felt wrong.

That's why there is tiny DateTimy, it's a tiny (150 lines without comments) extension for the native DateTime object and therefore 100% compatible with it.

It brings common formats (sql, javascript, rss...), translated time formats (using LOCALE), a more resilient constructor and "automatic" timezone conversion.

Installation

Install this package using composer:

Usage

You can use the DateTimy class in exactly the same way you would work with a DateTime object.

Features

Timezone conversion

The concept of timezone conversion is build on the assumption that you have (for the most part) two different main timezones you work with. a.) the timezone of your server (in my reality UTC for the most part) and b.) the timezone of the client when you render a time for the end user.

So by default all new instances of the DateTimy class will be set to the "server" timezone which is UTC. The given $time given to the constructor is also assumed to be in the "server" timezone until you provide another timezone manually.

If you want to convert the timezone to your client's needs you can use the "toClient()" method. By default, the "client" timezone is defined by date_default_timezone_get() until you manually change it.

To configure the timezones you can use the static configureTimezone() method to set both timezones to your needs.

Extended constructor

The constructor of the DateTimy class was extended to handle different time options more reliable than the default constructor would.

Numeric values

Numeric values will automatically be parsed as timestamp, so no need to put an "@" in front of it.

Cloning / Transforming Datetime objects

You can pass an instance of a DateTime() or DateTimy() class as $time. The constructor will handle the conversion for you

Timezone from string

The constructor can now handle timezones based on a string as well as the default DateTimeZone() objects.

Using a format

While using createFromFormat() to create a new instance based on a string that follows a non-standard format is still possible, the constructor now has the capability to read a string from a format as well.

Common Formats

I am a lazy person when it comes to work I have to do repeatedly. Date / Time Formats in PHP is such a task. Therefore the class provides you with some preconfigured formats and the option to change them or to create completely new ones. The default formats included are:

All formats can be applied using the "format" method, or by using the magic method that brings support for every registered format like: formatDateAndTime()

You can add a new format or modify preconfigured formats using the configureFormat() method.

After you added your own format you can use it like any preconfigured format like:

Localized formatting

By default php only translates your time formats for month or weekday names only when you use the strftime() method. This is not supported for DateTime objects and requires its own special syntax (I forget the chars every time...).

For that the DateTimy class provides you with the formatLocalized() method. It translates F, l, M or D based on your current LOCALE exactly like strftime() would while keeping the same syntax as format() does!

Running tests

Special Thanks

Special thanks goes to the folks at LABOR.digital (which is the word german for laboratory and not the english "work" :D) for making it possible to publish my code online.

Postcardware

You're free to use this package, but if it makes it to your production environment I highly appreciate you sending me a postcard from your hometown, mentioning which of our package(s) you are using.

You can find my address here.

Thank you :D


All versions of tiny-timy with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3 <8.4
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 neunerlei/tiny-timy contains the following files

Loading the files please wait ....