Skip to content

CYCLOPS Jalali date & time is an extension for Yii2. It's a fork of Jalali date & time.

Notifications You must be signed in to change notification settings

cyclops24/yii2-jdate

 
 

Repository files navigation

CYCLOPS Jalali Date (Yii2 Extension)

CYCLOPS Jalali date & time is an extension for yii2. It's a fork of Jalali date & time presented by Mohammad Mahdi Gholamian. This fork works with jdf (Jalali Date Function) presented by Reza Gholampanahi.

Installation

The preferred way to install this extension is through composer.

add

"repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/cyclops24/yii2-jdate"
        }
    ],

to your composer.json root section and then

"cyclops24/yii2-jdate": "*"

to the require section.

Usage of DateTime

Once the extension is installed, add it as a component in your config file:

'jdate' => [
	'class' => 'jDate\DateTime'
]

Now you can use in your project:

echo Yii::$app->jdate->jdate('Y/m/d'); // ۱۳۹۳/۰۵/۰۳

Usage of DatePicker

It is a widget to make a input, box to giver jalali date from user.

A basic usage:

<?= jDate\DatePicker::widget([
	'name' => 'datepicker'
]) ?>

If you want set default date set value:

<?= jDate\DatePicker::widget([
	'name' => 'datepicker', 'value' => '1394/01/01'
]) ?>

Using a model:

<?= jDate\DatePicker::widget([
	'model' => $model, 'attribute' => 'date'
]) ?>

Use in active form:

<?= $form->field($model, 'fieldname')->widget(jDate\DatePicker::className()) ?>

###Datepicker ClientOptions###

Add these to ClientOptions var.

####Change date picker size:

[
	'cellHeight' => 13,
	'cellWidth'  => 13
]

####Change font size:

[
	'fontSize' => 25
]

####Use english numbers in date picker:

[
	'persianNumbers' => false
]

####Date format:

[
	'formatDate' => 'DD-NM-YYYY hh:m'
]

###Datepicker Theme###

Now date picker have 2 theme default and dark.

For set theme set theme var.

<?= jDate\DatePicker::widget([
	'model' => $model, 'attribute' => 'date', 'theme' => 'dark'
]) ?>

###Datepicker Events#####

NOTE : If you want rewriting onSelect event and using active form add options[id] and add

$('#your id').trigger('change');

> 
> to your event function.

####`onHide` Event:

```php
<?= jDate\DatePicker::widget([
	'model' => $model, 'attribute' => 'date',
	'ClientOptions' => [
		'onHide' => 'function(){alert("Datepicker is now hidden!")}'
	]
]) ?>

####onSelect Event:

<?= jDate\DatePicker::widget([
	'model' => $model, 'attribute' => 'date',
	'ClientOptions' => [
		'onSelect' => 'function(){alert("Date selected!")}'
	]
]) ?>

####onShow Event:

<?= jDate\DatePicker::widget([
	'model' => $model, 'attribute' => 'date',
	'ClientOptions' => [
		'onShow' => 'function(){alert("Hello!")}'
	]
]) ?>

About

CYCLOPS Jalali date & time is an extension for Yii2. It's a fork of Jalali date & time.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 59.8%
  • JavaScript 30.6%
  • CSS 7.7%
  • Shell 1.9%