Download the PHP package omnilight/yii2-datetime without Composer

On this page you can find all versions of the php package omnilight/yii2-datetime. 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 yii2-datetime

Date and Time behaviors for Yii 2

This extension helps you to deal with date and time attributes of the models for Yii framework 2.0

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json.

Why?

When working with models and forms it is often needed to provide user a way to edit attributes that holds date and/or time. In this case typical problems are:

  1. Date/time formats could be different in the database and in the displayed form (due to local settings, for ex.)
  2. You should validate values entered by the user

So you have to set correct format for database, form, somehow convert them from one to another, and it would be nice if you can setup correct formats once (on application level) and lately do not worry about them. This extension helps is this area.

The idea

Idea is to have separate attribute for each editable date/time property of the model, that will be used in the form. This attribute will not be stored in the DB, but it will be used to present user with correctly formatted value. And when you assign value to this attribute, it will be automatically converted and assigned to the DB property of the model.

This extension provides special behavior, that automates work with this attributes

How to use

In your model:

Now in your view with the form:

That's all! User will enter date in the his local format and will be converted to the database automatically.

How is works

Behavior creates "virtual" attribute named attribute_name_local for each attribute you define in the 'attributes' section. When you read $yourModel->attribute_name_local behavior will return object with the type DateTimeAttribute. If this object will be used in the string context, it will be converted to string with the magical __toString method. And during this original value of attribute_name will be converted into the local representation.

When you assign value to the $yourModel->attribute_name_local internally it will be assigned to value property of the DateTimeAttribute class and converted to the your database-stored property.

You can also define individual configuration for each attribute and define it's local name, format and so on.


All versions of yii2-datetime with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
yiisoft/yii2 Version *
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 omnilight/yii2-datetime contains the following files

Loading the files please wait ....